HTTP Cats

Every cat now speaks JSON

Add .json to any status code and you get its name and description as JSON.

The cats have always been easy to use: https://http.cat/404 is the 404 cat, ready for an <img> tag. The text on each status page, though, was only available as HTML. That's what issue #42 asked for back in January 2020: donpdonp wanted a data source for an IRC bot that answers !http 401, and suggested /401.json. It took a while, but it's here, and it's exactly that URL.

Usage

Every status has a JSON URL, https://http.cat/<code>.json:

curl https://http.cat/418.json
{
  "status": 418,
  "name": "I’m a teapot",
  "description": "The HTTP `418 I'm a teapot` client error response code indicates that the server refuses to brew coffee because it is, permanently, a teapot. ...",
  "image": "https://http.cat/418",
  "url": "https://http.cat/status/418"
}
  • status and name: the code and its reason phrase.
  • description: the same text as the status page, as Markdown, including its links and sources.
  • image and url: the cat and the status page.

That IRC bot is now a one-liner:

curl -s https://http.cat/401.json | jq -r '"\(.status) \(.name)"'
# 401 Unauthorized

The JSON is sent with Access-Control-Allow-Origin: *, so you can also fetch it from your own site:

const res = await fetch('https://http.cat/503.json');
const { name, image } = await res.json();

Unknown codes

A code without a cat, like /999.json, returns a 404 with the body of /404.json. Every 404 on this site is the 404 cat, and that's the 404 cat's JSON. So check the HTTP status of the response, not the status field:

const res = await fetch('https://http.cat/999.json');
if (!res.ok) {
  // no such status
}

Thanks to everyone who chimed in on the issue over the years. Have fun with it, and let me know what you build.