{"openapi":"3.1.0","info":{"title":"WikiPortraits Photo Service API","version":"0.1.0","description":"Read-only access to the WikiPortraits Photo Service photo catalogue. Photos are taken by\nWikiPortraits photographers and published on Wikimedia Commons under Creative\nCommons licenses. A file that Commons marks as cropped from another photo in\nthe catalogue is left out; its Wikipedia uses count toward the original.\n\n> **Alpha. For testing only.** This API may change or be removed without\n> notice. Do not use it in production.\n\n## Authentication\n\nEvery `/api/v1` request needs an API key. To get one,\n[register](https://photos.wikiportraits.org/auth/register) or [log in](https://photos.wikiportraits.org/auth/login),\nverify your email address, then create a key under **API Keys** on your\n[profile page](https://photos.wikiportraits.org/profile#api-keys). If a key leaks, regenerate it\nthere: the old secret stops working at once and the new one keeps the key's\nname and rate limit. Send the key in the `Authorization` header:\n\n```\nAuthorization: Bearer wp_...\n```\n\nRequests without a valid key get a `401`. Thumbnails need no key.\n\n## Rate limits\n\n**60 requests per minute** per key. Responses include\n`RateLimit` and `RateLimit-Policy` headers; a `429` also sends\n`Retry-After`. Need more? Email\n[hello@wikiportraits.org](mailto:hello@wikiportraits.org) with the key's name and we can raise\nits limit.\n\nThe thumbnail proxy has a separate limit of 120 requests per minute per IP.\n\n## Invalid parameters\n\nBad filter values are ignored. A malformed date, a subject ID\nthat is not `Q` plus digits, or a non-numeric event ID is dropped and the\nsearch runs without it. `/api/v1/photos` returns the filters it used in\n`filters`. A `limit` over 100 is cut to 100; a `limit` or `page`\nthat is not a positive number falls back to its default. An unknown `sort`\nis treated as `best`.\n\n## Images\n\nEach photo carries two sets of thumbnail URLs at the same 6\nwidths. `commonsThumbnails` point straight at `thumb.wikimedia.org` and\nwork from anywhere. `thumbnails` point at this site's proxy, which only\nserves pages on this site and on approved domains; from anywhere else it\nanswers with a `302` to the Commons URL. Use `commonsThumbnails` unless\nyour domain has been approved. To ask for approval, email\n[hello@wikiportraits.org](mailto:hello@wikiportraits.org) with the domain.\n\n## Licensing and credit\n\nEvery photo has a Creative Commons license. Each photo object gives the\nlicense name (`license`), a link to it (`licenseUrl`) and a link to the\nCommons file page (`commonsUrl`). Use `attribution` or `attributionHtml` as\nthe credit line. CC0 and public domain files have `creditRequired: false`.\nThe license covers copyright only. Personality rights still apply to the\npeople shown.","contact":{"email":"hello@wikiportraits.org"}},"servers":[{"url":"https://photos.wikiportraits.org"}],"security":[{"ApiKey":[]}],"tags":[{"name":"Photos","description":"Search the catalogue."},{"name":"Subjects","description":"People and groups in the photos, by Wikidata ID."},{"name":"Events","description":"Where photos were taken. Events can have child events, such as a yearly edition of a festival."},{"name":"Thumbnails","description":"Resized images, proxied from Wikimedia."}],"paths":{"/api/v1/photos":{"get":{"tags":["Photos"],"summary":"Search photos","operationId":"searchPhotos","description":"Returns a page of photos matching all given filters. With no filters, returns the whole catalogue.","parameters":[{"name":"q","in":"query","description":"Search text. Each word is matched as a prefix against photo descriptions, file names and event names, ignoring case and accents: `fest` finds `festival`. A photo matches when every word matches, or when an event name contains the text. Cut to 200 characters.","schema":{"type":"string","maxLength":200},"example":"sundance film festival"},{"name":"subject","in":"query","description":"Wikidata ID of a person or group in the photo. See `/api/v1/subjects`.","schema":{"type":"string","pattern":"^Q\\d+$"},"example":"Q295803"},{"name":"event_id","in":"query","description":"Event ID. Includes child events. Overrides `event_ids`. See `/api/v1/events`.","schema":{"type":"integer","minimum":1},"example":4},{"name":"event_ids","in":"query","description":"Comma-separated event IDs. Matches photos from any of them or their child events. Ignored if `event_id` is set.","schema":{"type":"string","pattern":"^\\d+(,\\d+)*$"},"example":"4,7,12"},{"name":"photographer","in":"query","description":"Photographer name, exactly as in the `author` field.","schema":{"type":"string","maxLength":300},"example":"Jane Photographer"},{"name":"from","in":"query","description":"Only photos taken on or after this date.","schema":{"type":"string","format":"date"},"example":"2024-01-01"},{"name":"to","in":"query","description":"Only photos taken on or before this date.","schema":{"type":"string","format":"date"},"example":"2024-12-31"},{"name":"highlighted","in":"query","description":"`1`, `true` or `yes`: only photos site admins picked as highlights (`isHighlighted: true`). These are the photos the gallery home page shows. Any other value, or leaving it out, returns all photos. Combines with the other filters.","schema":{"type":"boolean"},"example":true},{"name":"page","in":"query","description":"Page number, starting at 1.","schema":{"type":"integer","minimum":1,"default":1}},{"name":"limit","in":"query","description":"Photos per page. Values over 100 are cut to 100; a non-number or anything under 1 means 20.","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"sort","in":"query","description":"`best`: most used on Wikimedia wikis first, then highest resolution. `recent`: newest first. Both fall back to the Commons upload date when `dateTaken` is `null`, so an undated photo sorts by when it was uploaded, not at the end.","schema":{"type":"string","enum":["best","recent"],"default":"best"}}],"responses":{"200":{"description":"A page of matching photos.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhotoSearchResult"},"example":{"photos":[{"id":1234,"commonsTitle":"File:Example portrait.jpg","fileName":"Example portrait.jpg","description":"Portrait taken at WikiConference 2024","dateTaken":"2024-08-10","author":"Jane Photographer","license":"CC BY-SA 4.0","licenseUrl":"https://creativecommons.org/licenses/by-sa/4.0","creditRequired":true,"attribution":"Jane Photographer / WikiPortraits, CC BY-SA 4.0. Source: https://photos.wikiportraits.org/photos/165144720","attributionHtml":"Jane Photographer / WikiPortraits, <a href=\"https://creativecommons.org/licenses/by-sa/4.0\">CC BY-SA 4.0</a> (<a href=\"https://photos.wikiportraits.org/photos/165144720\">source</a>)","width":3000,"height":4000,"isHighlighted":false,"wikiUsageCount":7,"thumbnails":{"250":"https://photos.wikiportraits.org/thumb/Example%20portrait.jpg?width=250","500":"https://photos.wikiportraits.org/thumb/Example%20portrait.jpg?width=500","960":"https://photos.wikiportraits.org/thumb/Example%20portrait.jpg?width=960","1280":"https://photos.wikiportraits.org/thumb/Example%20portrait.jpg?width=1280","1920":"https://photos.wikiportraits.org/thumb/Example%20portrait.jpg?width=1920","3840":"https://photos.wikiportraits.org/thumb/Example%20portrait.jpg?width=3840"},"commonsThumbnails":{"250":"https://thumb.wikimedia.org/wikipedia/commons/thumb/6/6b/Example_portrait.jpg/250px-Example_portrait.jpg","500":"https://thumb.wikimedia.org/wikipedia/commons/thumb/6/6b/Example_portrait.jpg/500px-Example_portrait.jpg","960":"https://thumb.wikimedia.org/wikipedia/commons/thumb/6/6b/Example_portrait.jpg/960px-Example_portrait.jpg","1280":"https://thumb.wikimedia.org/wikipedia/commons/thumb/6/6b/Example_portrait.jpg/1280px-Example_portrait.jpg","1920":"https://thumb.wikimedia.org/wikipedia/commons/thumb/6/6b/Example_portrait.jpg/1920px-Example_portrait.jpg","3840":"https://upload.wikimedia.org/wikipedia/commons/6/6b/Example_portrait.jpg"},"pageUrl":"https://photos.wikiportraits.org/photos/165144720","commonsUrl":"https://commons.wikimedia.org/wiki/File:Example%20portrait.jpg"}],"pagination":{"total":842,"page":1,"limit":20,"totalPages":43},"sort":"best","filters":{"q":"conference","subject":null,"photographer":null,"from":null,"to":null,"highlighted":false}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/subjects":{"get":{"tags":["Subjects"],"summary":"Search subjects","operationId":"searchSubjects","description":"Lists people and musical groups that appear in photos, with a photo count for each. Use the `qid` as the `subject` filter on `/api/v1/photos`.\n\nWith `q`, returns up to 10 subjects whose name contains the text. Without it, returns the top 20. Both are sorted by English Wikipedia page views, then by photo count, then by name. The view count is a 7-day total taken during the nightly import, so it lags the live pageviews API by up to a day and is not recomputed per request. Subjects with no English Wikipedia article count as 0 views.\n\nThe other parameters limit which photos are counted.","parameters":[{"name":"q","in":"query","description":"Name search, ignoring case. Cut to 200 characters.","schema":{"type":"string","maxLength":200},"example":"olympics"},{"name":"keyword","in":"query","description":"Search text to filter the photos being counted. Works like `q` on `/api/v1/photos`. (`q` here searches names.)","schema":{"type":"string","maxLength":200}},{"name":"photographer","in":"query","description":"Photographer name, exactly as in the `author` field.","schema":{"type":"string","maxLength":300},"example":"Jane Photographer"},{"name":"event_id","in":"query","description":"Event ID. Includes child events. Overrides `event_ids`. See `/api/v1/events`.","schema":{"type":"integer","minimum":1},"example":4},{"name":"event_ids","in":"query","description":"Comma-separated event IDs. Matches photos from any of them or their child events. Ignored if `event_id` is set.","schema":{"type":"string","pattern":"^\\d+(,\\d+)*$"},"example":"4,7,12"},{"name":"from","in":"query","description":"Only photos taken on or after this date.","schema":{"type":"string","format":"date"},"example":"2024-01-01"},{"name":"to","in":"query","description":"Only photos taken on or before this date.","schema":{"type":"string","format":"date"},"example":"2024-12-31"}],"responses":{"200":{"description":"Matching subjects.","headers":{"Cache-Control":{"$ref":"#/components/headers/FilterCacheControl"}},"content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Subject"}},"example":[{"qid":"Q295803","label":"Tom Hiddleston","count":12},{"qid":"Q615","label":"Lionel Messi","count":3}]}}},"401":{"$ref":"#/components/responses/Unauthorized"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/events":{"get":{"tags":["Events"],"summary":"List events","operationId":"listEvents","description":"Returns all events, grouped by type. Use an `id` with the `event_id` or `event_ids` filters. Events with no type are listed under `Other`; there may be none.","responses":{"200":{"description":"Events by type. Within a type, events are in plain code-point order of their name: capitals before lower case, accented letters after `z`. Types are in the same order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventsByType"},"example":{"film festivals":[{"id":4,"displayName":"Cannes Film Festival"},{"id":7,"displayName":"2025 Cannes Film Festival"}],"music festivals":[{"id":12,"displayName":"2025 Eurovision Song Contest"}]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/thumb/{fileName}":{"get":{"tags":["Thumbnails"],"summary":"Fetch a thumbnail","operationId":"getThumbnail","security":[],"description":"Returns a resized photo. Each photo in `/api/v1/photos` includes a `thumbnails` map with URLs for this endpoint at 6 widths.\n\nThe width is rounded to the nearest size Wikimedia pre-renders: 20, 40, 60, 120, 250, 330, 500, 960, 1280, 1920, 3840. A width at or above the original's returns the original file.\n\nRequests whose `Referer` or `Origin` is not this site or an approved domain are not proxied: they get a `302` straight to the thumbnail file on `thumb.wikimedia.org`, the same URL as in `commonsThumbnails`. Follow redirects, or use `commonsThumbnails` from the start. Proxied images are cached by browsers for 3 days and by the CDN for 30, and the cache does not key on `Referer`, so a size the site has already served may come back as a `200` without one. Do not rely on either outcome.","parameters":[{"name":"fileName","in":"path","required":true,"description":"The `fileName` from `/api/v1/photos`, URL-encoded: a space is `%20`, not `_`. The `thumbnails` map already has it encoded. Only files in the catalogue are served.","schema":{"type":"string","maxLength":500},"example":"Example%20portrait.jpg"},{"name":"width","in":"query","required":true,"description":"Width in pixels. Rounded to the nearest pre-rendered size.","schema":{"type":"integer","minimum":1,"maximum":5000},"example":500}],"responses":{"200":{"description":"The image, usually JPEG.","content":{"image/*":{"schema":{"type":"string","format":"binary"}}}},"302":{"description":"Request did not come from this site or an approved domain. `Location` points to the thumbnail file on `thumb.wikimedia.org`, or to the original on `upload.wikimedia.org` when the width is at or above the original's.","headers":{"Location":{"schema":{"type":"string","format":"uri"},"description":"Direct thumbnail URL, e.g. `https://thumb.wikimedia.org/wikipedia/commons/thumb/a/ab/Example_portrait.jpg/500px-Example_portrait.jpg`."}}},"400":{"description":"`width` is missing or not between 1 and 5000, or the file name is over 500 characters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid width — must be 1–5000"}}}},"404":{"description":"File name not in the catalogue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Photo not found"}}}},"429":{"description":"Over the limit of 120 requests per minute per IP (sends `Retry-After`), or the shared limit on requests to Wikimedia.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Too many requests"}}}},"502":{"description":"Wikimedia returned an error or closed the connection.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Failed to fetch thumbnail"}}}},"504":{"description":"Wikimedia did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Upstream request timed out"}}}}}}}},"components":{"securitySchemes":{"ApiKey":{"type":"http","scheme":"bearer","description":"An API key from your [profile page](https://photos.wikiportraits.org/profile#api-keys)."}},"schemas":{"Photo":{"type":"object","required":["id","commonsTitle","fileName","description","dateTaken","author","license","licenseUrl","creditRequired","attribution","attributionHtml","width","height","isHighlighted","wikiUsageCount","thumbnails","commonsThumbnails","pageUrl","commonsUrl"],"properties":{"id":{"type":"integer","description":"Internal row ID. Not the Commons page ID, and not what `pageUrl` uses. Stable across imports, but of no use outside this API."},"commonsTitle":{"type":"string","description":"Page title on Wikimedia Commons, with the `File:` prefix."},"fileName":{"type":"string","description":"File name on Commons, without the `File:` prefix, with spaces as spaces. URL-encode it for `/thumb/{fileName}` (space becomes `%20`)."},"description":{"type":["string","null"],"description":"Description from the Commons file page."},"dateTaken":{"type":["string","null"],"description":"Date taken, usually `YYYY-MM-DD`. `null` when Commons has no date; sorting then uses the upload date."},"author":{"type":["string","null"],"description":"Photographer, as credited on Commons."},"license":{"type":["string","null"],"description":"License name, e.g. `CC BY-SA 4.0`."},"licenseUrl":{"type":["string","null"],"format":"uri","description":"Link to the license on creativecommons.org, taken from the Commons file page when it gives one. Whether it ends in a slash varies; compare URLs with care."},"creditRequired":{"type":"boolean","description":"`false` for CC0 and public domain files."},"attribution":{"type":"string","description":"Plain-text credit line: author, license and source link."},"attributionHtml":{"type":"string","description":"The credit line as HTML, with links. The author name is escaped."},"width":{"type":"integer","description":"Original width in pixels."},"height":{"type":"integer","description":"Original height in pixels."},"isHighlighted":{"type":"boolean","description":"Picked as a highlight by site admins. Rare; most photos are `false`."},"wikiUsageCount":{"type":"integer","minimum":0,"description":"Number of pages on Wikimedia wikis (Wikipedia, Wikidata, etc.) that use the photo or a crop of it. Excludes Commons and Meta."},"thumbnails":{"type":"object","description":"Thumbnail URLs on this site's proxy, by width in pixels. Only pages on this site and on approved domains are served; others are redirected to the Commons URL. See `/thumb/{fileName}`.","properties":{"250":{"type":"string","format":"uri"},"500":{"type":"string","format":"uri"},"960":{"type":"string","format":"uri"},"1280":{"type":"string","format":"uri"},"1920":{"type":"string","format":"uri"},"3840":{"type":"string","format":"uri"}},"required":["250","500","960","1280","1920","3840"]},"commonsThumbnails":{"type":"object","description":"Thumbnail URLs on `thumb.wikimedia.org`, by width in pixels, at the same widths as `thumbnails`. Usable from any site. A width at or above the original's gives the original file's URL on `upload.wikimedia.org`.","properties":{"250":{"type":"string","format":"uri"},"500":{"type":"string","format":"uri"},"960":{"type":"string","format":"uri"},"1280":{"type":"string","format":"uri"},"1920":{"type":"string","format":"uri"},"3840":{"type":"string","format":"uri"}},"required":["250","500","960","1280","1920","3840"]},"pageUrl":{"type":"string","format":"uri","description":"Photo page on this site, `/photos/{commonsPageId}`. The number is the file's Wikimedia Commons page ID, not `id`. The credit line links here."},"commonsUrl":{"type":"string","format":"uri","description":"File page on Wikimedia Commons."}}},"PhotoSearchResult":{"type":"object","required":["photos","pagination","sort","filters"],"properties":{"photos":{"type":"array","items":{"$ref":"#/components/schemas/Photo"}},"pagination":{"type":"object","required":["total","page","limit","totalPages"],"properties":{"total":{"type":"integer","description":"Total matching photos."},"page":{"type":"integer","description":"Current page."},"limit":{"type":"integer","description":"Photos per page."},"totalPages":{"type":"integer","description":"Total pages."}}},"sort":{"type":"string","enum":["best","recent"],"description":"Sort order used."},"filters":{"type":"object","description":"Filters used. Invalid values come back as `null`. Event filters are not included.","required":["q","subject","photographer","from","to","highlighted"],"properties":{"q":{"type":["string","null"]},"subject":{"type":["string","null"]},"photographer":{"type":["string","null"]},"from":{"type":["string","null"]},"to":{"type":["string","null"]},"highlighted":{"type":"boolean","description":"`true` when the `highlighted` filter was on."}}}}},"Subject":{"type":"object","required":["qid","label","count"],"properties":{"qid":{"type":"string","pattern":"^Q\\d+$","description":"Wikidata ID."},"label":{"type":"string","description":"Name."},"count":{"type":"integer","description":"Photos the subject appears in."}}},"Event":{"type":"object","required":["id","displayName"],"properties":{"id":{"type":"integer","description":"Event ID."},"displayName":{"type":"string","description":"Event name."}}},"EventsByType":{"type":"object","description":"Events grouped by type. Events with no type are under `Other`.","additionalProperties":{"type":"array","items":{"$ref":"#/components/schemas/Event"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message."}}}},"headers":{"FilterCacheControl":{"description":"Results may be cached for 5 minutes.","schema":{"type":"string"},"example":"private, max-age=300"}},"responses":{"Unauthorized":{"description":"Missing, invalid or revoked API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid API key"}}}},"RateLimited":{"description":"Over 60 requests with this key in the last minute.","headers":{"RateLimit":{"description":"Limit, requests remaining, and seconds until reset.","schema":{"type":"string"},"example":"limit=60, remaining=0, reset=42"},"RateLimit-Policy":{"description":"Limit and window in seconds.","schema":{"type":"string"},"example":"60;w=60"},"Retry-After":{"description":"Seconds until the window resets.","schema":{"type":"integer"},"example":42}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Too many requests"}}}}}}}