Rankd for Developers
Checking API…

Guides

Errors

Errors use standard HTTP status codes and, almost always, one JSON shape.

The error body#

404 Not Found
{
  "error": {
    "code": "not_found",
    "message": "User not found."
  }
}
  • error.code is stable and machine-readable. Branch on it.
  • error.message is for people. Its wording can change, so never parse it.

Two exceptions#

Two errors are answered before a request reaches the API itself, and have a shorter body where error is a string:

StatusBodyWhen
429{"error":"rate limited"}Over the rate limit. Comes with Retry-After.
405{"error":"method not allowed"}A method other than GET, POST, PUT, PATCH or DELETE, such as HEAD or OPTIONS.

Handle both shapes:

const body = await response.json();
if (!response.ok) {
  const code = typeof body.error === 'string' ? body.error : body.error.code;
  throw new Error(`Rankd API ${response.status}: ${code}`);
}

Status codes#

StatusMeaning
200It worked.
304Images only: the copy you have is current.
400A parameter is invalid. error.code says which rule it broke.
401The endpoint needs a Rankd account. It is not one of the public endpoints, or the path does not exist.
404Not found, or not public. The API does not say which.
405That method is not allowed.
429Rate limited.
503Part of the API is unavailable. Try again later.

A path that does not exist answers 401 unauthenticated, not 404, when you are not signed in: the API checks for access before it checks whether the route exists. Check your path if you get a 401 from what should be a public endpoint.

Error codes#

CodeStatusMeaningFrom
invalid_music_reference400The music type or id is not one Rankd understands.Get an album, song or artist
Reviews of an album, song or artist
invalid_query400The search text is shorter than two characters.Search the catalogue
Search people
Search lists
invalid_type400type is not one of the documented values.Rankd Charts
invalid_username400Not something a Rankd username can be.Look up a user by username
unauthenticated401The endpoint needs a Rankd account, or the path does not exist.Any endpoint not on this site
not_found404It does not exist, or it is not public. The API does not say which.9 endpoints
catalogue_unavailable503The music catalogue is not available. Try again later.Search the catalogue
database_unavailable503The API cannot reach its database. Try again later.Health check

Retrying#

  • 429: wait for Retry-After seconds.
  • 503: back off (1 s, 2 s, 4 s…) and try a few times.
  • 400, 401, 404: do not retry; the answer will not change.
↑ ↓ to move↵ to open/ or ⌘K to search