---
title: "Search Wikimedia Commons for an image"
method: GET
path: "/api/media/commons/search"
tags: ["Proposing changes"]
---

# Search Wikimedia Commons for an image

`GET /api/media/commons/search`

## Request

- Base URL: `https://verifiedhandles.org`
- URL: `https://verifiedhandles.org/api/media/commons/search`
- Auth: HTTP bearer

The image picker’s Commons tab: up to 24 image files on Wikimedia Commons, each with a signed `token` that names it to the site. It asks Commons; when Commons does not answer in time, no results. A file name (with or without `File:`) also finds that exact file, first, even before Commons’ search has caught up with it. Files withdrawn or restricted here are left out. Fewer than 2 characters asks nothing. 60 a minute per account.

## Query parameters

- `q` string, required

## Response `200`

The files.

- object
  - `results` CommonsHit[], required
    - `filename` string, required
    - `width` integer, nullable, required
    - `height` integer, nullable, required
    - `mime` string, nullable, required
    - `token` string, required: The file, signed for 30 minutes: what `POST /api/media/commons` and the preview take.
    - `commonsPage` string, required: The file’s page on Commons, with its licence and author.

## Other responses

- `400`: The text is over 200 characters (`query_too_long`). Or the request sent a key and a session cookie together (`bearer_with_cookie`): send one.
- `401`: No key was sent (`auth_required`), or the key was refused: unknown, revoked or expired, its holder may no longer use keys, or this instance takes none. Carries `WWW-Authenticate: Bearer`. After 60 refused keys from one IP address in a minute, every key from there is answered `429` (text, with `Retry-After`) until the minute is up.
- `403`: A read-only key tried to change something (`read_only_key`), or the account is blocked (`forbidden`).
- `429`: Too many changes in the last minute: counted per IP address, per account and per key (an admin key’s per key alone, at the limit set on Console → Rate limits). Wait the number of seconds `Retry-After` gives.
- `503`: The site is down for maintenance. The body is the maintenance page, as HTML. Try again later: `Retry-After` gives the seconds.

---

[API](https://skmtc.dev/verifiedhandles/apis/verified-handles-api.md) · [All operations](https://skmtc.dev/verifiedhandles/apis/verified-handles-api/llms.txt) · [OpenAPI document](https://skmtc.dev/verifiedhandles/apis/verified-handles-api/revisions/40720de2e0ec?raw)
