AnalogDB

the collection of film photography

AnalogDB

Overview

This document outlines the AnalogDB API. This API provides film photographs and metadata in JSON form as a REST-style service. The API is open-source and available on github. The swagger docs are available here.

The AnalogDB project is currently under development and subject to change. All film pictures are scraped from reddit. All credit goes to the original photographers.

Use the following URI to access the endpoints: https://api.analogdb.com/v1. Paths without /v1 have been removed.

Rate Limiting

The Analogdb API currently places a limit of 60 requests/min. Current rate limit status is returned in response headers after each request including remaining requests and reset time in unix epoch seconds. Requests over the limit return status 429.

x-ratelimit-limit: 60
x-ratelimit-remaining: 59
x-ratelimit-reset: 1691712960

Errors

Errors return a non 2xx status with a JSON body holding a message.

{"error": "post not found"}
paramdescription
400invalid parameter or request
404post or keyword not found
413uploaded image is larger than 5 MB
415uploaded image is not JPEG, PNG or WebP
429rate limit exceeded
500internal server error
503search is busy, try again shortly

Pagination

/posts and /search are paginated with cursors. By default, 20 posts are returned per page. Pass the next_cursor from one response to get the next page, or follow next_page_url, a path relative to /v1. Other endpoints return a single page sized by page_size.

paramdescription
page_sizeset the number of records to return on each page (default 20, maximum 200)
cursorrequest the next page of results. Each request returns a next_cursor that can be passed back to access the next page of results
curl https://api.analogdb.com/v1/posts?page_size=10&cursor=eyJzIjoidGltZSIsInYiOjE3OTA1Mzk5MjIsImlkIjo0MDA1Mn0

Resources

Image

The image resource contains the image URL as well as resolution and dimensions.

field nametypedescription
urlstringlink to image
resolutionstringlow, medium, high, raw
widthintegerwidth of image in pixels
heightintegerheight of image in pixels

Color

The color resource represents primary colors extracted from images and corresponding percentages.

field nametypedescription
cssstringCSS color name (e.g., dimgray)
hexstringhex color code (e.g., #837d5c)
htmlstringHTML color name (e.g., gray)
percentnumberpercent of image this color represents

Keyword

The keyword resource contains keywords scraped from post along with relevance score.

field nametypedescription
wordstringdetected keyword in image
weightnumberrelevance of keyword (0-1)

Post

The post resource contains a list of image(multiple resolutions) as well as metadata about the post including timestamp, score, camera, film, colors, keywords, etc. Fields that are unknown, such as camera or film, are left out.

field nametypedescription
idintegerunique identifier
titlestringtitle of post
authorstringauthor of post
permalinkstringurl of post source
scoreintegertotal votes of post
timestampintegertime of post creation (unix time)
createdstringtime the post was added to AnalogDB (RFC 3339)
updatedstringtime the post was last changed in AnalogDB (RFC 3339)
descriptionstringpost description
captionstringgenerated description of the image
camera_makestringcamera manufacturer (e.g., nikon)
camera_modelstringcamera model (e.g., fm2)
film_makestringfilm manufacturer (e.g., kodak)
film_typestringfilm type (e.g., portra 400)
film_speedintegerfilm ISO speed (e.g., 400)
aperturestringaperture setting (e.g., f/2.0)
focal_lengthintegerfocal length in mm (e.g., 35)
nsfwboolimage is NSFW (not safe for work, 18+)
grayscaleboolimage is grayscale (black & white)
sprocketboolimage is a sprocket shot (exposed film sprockets)
imagesarray[image]list of images at different resolutions
colorsarray[color]dominant colors extracted from image
keywordsarray[keyword]keywords extracted from post

Catalog Post

The catalog post resource is a short form of a post, attached to cameras, films and keywords.

field nametypedescription
idintegerunique identifier
titlestringtitle of post
scoreintegertotal votes of post
imagesarray[image]list of images at different resolutions

Camera

The camera resource contains film cameras used in posts including manufacturer, model, and description and post count.

field nametypedescription
idintegerunique identifier
makestringcamera manufacturer (e.g., nikon)
modelstringcamera model (e.g., fm2)
slugstringurl name (e.g., nikon-fm2)
descriptionstringdescription of camera
post_countintegernumber of posts using this camera
top_postsarray[catalog post]highest scoring posts, only when top_posts is set
createdstringtimestamp when camera was added
updatedstringtimestamp when camera was last updated

Film

The film resource contains film stocks used in posts, including manufacturer, type, speed, and post count.

field nametypedescription
idintegerunique identifier
makestringfilm manufacturer (e.g., kodak)
typestringfilm type (e.g., portra 400)
slugstringurl name (e.g., kodak-portra-400)
speedintegerfilm ISO speed (e.g., 400)
color_typestringcolor or black & white film
descriptionstringdescription of film
post_countintegernumber of posts using this film
top_postsarray[catalog post]highest scoring posts, only when top_posts is set
createdstringtimestamp when film was added
updatedstringtimestamp when film was last updated

Meta

The meta resource contains supplementary information for a collection of post resources, including pagination details and total counts.

field nametypedescription
total_postsintegertotal number of posts served by endpoint query
page_sizeintegermaximum number of posts returned per page
next_cursorstringcursor for the next page, empty on the last page
next_page_urlstringpath of the next page, relative to /v1
seedintegerrandom seed used for random sorting

Search Result

The search result resource is returned by both search endpoints.

field nametypedescription
metaobjectpage_size, next_cursor and next_page_url, as in meta
postsarray[post]matching posts
related_keywordsarray[string]keywords related to the search, first page only

Endpoints

/posts

Returns a collection of post resources with accompanying meta resource. Supports extensive filtering and sorting options.

General Parameters

Posts can be sorted by time, score, or pseudo-randomly. Limits can be placed for maximum number of returned posts. If total number of posts exceeds the limit, results will be paginated.

paramdescriptiondefaultoptions
sorthow to order the posts. color ranks by how much of the given colors a post has, or gives a rainbow when no color is settimetime, score, random, color
page_sizemaximum number of posts returned201-200
cursorcursor of page to retrieve, from next_cursornull
seedrandom seed for consistent random sortingnullinteger
curl https://api.analogdb.com/v1/posts?sort=score&page_size=50

Filter Parameters

Posts can be filtered by various criteria including camera, film, time, colors, keywords, and image dimensions. For boolean filters (nsfw, grayscale, sprocket) if not provided, all posts are included; if set to true, only that type is returned; if set to false, that type is excluded.

paramdescription
idfilter by post ID
titlefilter by post title
authorfilter by author
time_startfilter by start time (unix timestamp)
time_endfilter by end time (unix timestamp)
camera_makefilter by camera make
camera_modelfilter by camera model
film_makefilter by film make
film_typefilter by film type
film_speedfilter by film speed
focal_lengthfilter by focal length
aperturefilter by aperture
nsfwfilter nsfw (18+) posts (true=only, false=exclude)
grayscalefilter grayscale (black & white) posts (true=only, false=exclude)
sprocketfilter sprocket posts (true=only, false=exclude)
keywordfilter by keyword, repeat to require every keyword (e.g., keyword=beach&keyword=sunset)
colorfilter by color name (red, orange, tan, yellow, green, olive, teal, navy, purple, pink, gray, black, white, brown) or 6 digit hex (e.g., c0392b), repeat to require every color
min_colorminimum share of the image from 0 to 1 for each color, paired by position with color. Each color has a default, divided by the number of colors
width_minminimum picture width
width_maxmaximum picture width
height_minminimum picture height
height_maxmaximum picture height
ratio_minminimum picture aspect ratio
ratio_maxmaximum picture aspect ratio
curl 'https://api.analogdb.com/v1/posts?camera_make=nikon&film_make=kodak&grayscale=false&keyword=portrait'

/post/:id

Returns a single specific post resource as identified by ID.

curl https://api.analogdb.com/v1/post/1924

/post/:id/similar

Returns a collection of post resources that are visually similar to the specified post based on vector similarity of image embeddings. Results are a single page.

paramdescriptionoptions
page_sizemaximum number of similar posts to return1-50 (default: 12)
nsfwfilter nsfw (18+) posts (true=only, false=exclude)boolean
grayscalefilter grayscale (black & white) posts (true=only, false=exclude)boolean
sprocketfilter sprocket posts (true=only, false=exclude)boolean
curl 'https://api.analogdb.com/v1/post/1924/similar?page_size=20&nsfw=false'

/search

Returns a search result of posts matching a text query, searching image content, keywords, captions and titles together. Paginated with cursor.

paramdescriptionoptions
qsearch text (required)1-200 characters
page_sizenumber of posts per page1-100 (default: 50)
cursorcursor of page to retrieve, from next_cursorstring
nsfwfilter nsfw (18+) posts (true=only, false=exclude)boolean
grayscalefilter grayscale (black & white) posts (true=only, false=exclude)boolean
sprocketfilter sprocket posts (true=only, false=exclude)boolean
curl 'https://api.analogdb.com/v1/search?q=girl+at+sunset&grayscale=false'

/search/image

A POST that returns a search result of posts that look like an uploaded image. Results are a single page.

paramdescriptionoptions
imageimage to search with, as multipart form data (required)JPEG, PNG, WebP up to 5 MB
page_sizenumber of posts to return1-100 (default: 50)
nsfwfilter nsfw (18+) posts (true=only, false=exclude)boolean
grayscalefilter grayscale (black & white) posts (true=only, false=exclude)boolean
sprocketfilter sprocket posts (true=only, false=exclude)boolean
curl -F [email protected] 'https://api.analogdb.com/v1/search/image?page_size=20'

/cameras

Returns a collection of camera resources with optional filtering and sorting. Useful for discovering cameras (not extensive) and their post counts.

paramdescriptionoptions
sortsort orderalphabetical, counts
page_sizenumber of results to return1-1000
makefilter by camera makestring
modelfilter by camera modelstring
idfilter by specific camera IDinteger
include_countsinclude post countsboolean
exclude_zero_countsexclude cameras with zero post countsboolean
min_countonly return entries with at least this many posts, implies include_countsinteger
top_postsattach this many top scoring posts to each entry1-10
curl 'https://api.analogdb.com/v1/cameras?sort=counts&make=nikon&include_counts=true'

/films

Returns a collection of film resources with optional filtering and sorting. Useful for discovering film stocks (not extensive) and their post counts.

paramdescriptionoptions
sortsort orderalphabetical, counts
page_sizenumber of results to return1-1000
makefilter by film makestring
typefilter by film typestring
speedfilter by film speedinteger
colortypefilter by color type (the color_type field)string
idfilter by specific film IDinteger
include_countsinclude post countsboolean
exclude_zero_countsexclude films with zero post countsboolean
min_countonly return entries with at least this many posts, implies include_countsinteger
top_postsattach this many top scoring posts to each entry1-10
curl 'https://api.analogdb.com/v1/films?sort=counts&make=kodak&speed=400&exclude_zero_counts=true'

/keyword/:word

Returns the post count of one keyword, its top_posts as catalog post resources and related keywords that often appear with it. URL encode the word.

paramdescriptionoptions
top_postsnumber of top scoring posts1-10 (default: 6)
relatednumber of related keywords0-30 (default: 12)
curl https://api.analogdb.com/v1/keyword/beach?related=6

/keywords/summary

Returns the most common keywords, each with a word and post count.

paramdescriptionoptions
page_sizenumber of keywords to return1-500 (default: 50)
daysonly count posts created in the last days1-90
min_countonly return keywords on at least this many postsinteger
top_postsattach this many top scoring posts to each keyword1-10
curl 'https://api.analogdb.com/v1/keywords/summary?page_size=20&days=30'