Search API
Find xkcd comics from a description of a situation, from your own bot, editor plugin or script. It’s free, needs no key and allows requests from any website.
Please link to the comic on xkcd.com wherever you show a result (use the url field).
This search exists to send people to Randall Munroe’s work.
Search
GET https://findxkcd.infopanel.org/api/search?q=<text>&limit=<1–20>
q- The situation, in plain words. Required, at most 500 characters. A comic number (
327,#327,xkcd 327) or an exact title returns that comic first. limit- How many comics to return, 1 to 20. Default 5.
curl 'https://findxkcd.infopanel.org/api/search?q=too+many+competing+standards&limit=1'
{
"query": "too many competing standards",
"results": [
{
"num": 927,
"title": "Standards",
"url": "https://xkcd.com/927/",
"explain_url": "https://www.explainxkcd.com/wiki/index.php/927",
"alt": "Fortunately, the charging one has been solved now that we've all standardized on mini-USB. Or is it micro-USB? Shit.",
"img": "https://imgs.xkcd.com/comics/standards.png",
"published": "2011-07-20",
"score": 0.83
}
]
}
Results come best match first. score is the similarity between your text and the comic, from 0 to
1 (1 for a number or exact-title match). Weak matches are left out, so a query can return fewer results than
limit, or none. alt is the comic’s title text from xkcd.com.
One comic
GET https://findxkcd.infopanel.org/api/comic/<num>
Returns the same fields as a search result, without score, or 404 if there is no such comic.
Limits and errors
- 30 searches per minute per IP address. Over the limit you get
429with aRetry-Afterheader in seconds. - Searches are cached for a day, so new comics can take up to a day to appear.
- Errors are JSON,
{"error": "…"}:400for a missing or too-longqor a badlimit,404for an unknown comic,502if search is temporarily unavailable.