Errors

Most errors come back with a 200 status code. The API signals failure with an error key in the response body, not with the HTTP status, so checking status_code == 200 will let failures through as if they succeeded.

Always check the body:

const response = await fetch('https://api.srating.io/v1/team/get?team_id=87019264-8549-11ed-bf01-5296e1552828', {
  'headers': { 'X-API-KEY': 'YOUR_API_KEY' },
});

const data = await response.json();

if (data.error) {
  throw new Error(data.error);
}

An error response is always this shape, with error as a string:

{
  "error": "access denied"
}

Status codes

Only four requests ever get a non-200 status:

CodeBodyMeaning
400{"error": "Invalid JSON format"}The POST body wasn't valid JSON
400Bad RequestThe request had no URL at all
413{"error": "Content Too Large"}POST body over 1MB. The connection is closed
429{"error": "Too many requests"}You went over the rate limit

Everything else is 200 with an error key.

Access and key errors

ErrorWhat happened
access denied x-api-key header required.No X-API-KEY header. See Headers
access deniedThe key doesn't exist, or you don't have access to what you asked for
access denied, not v1The GET path isn't /v1/{class}/{function} — see Endpoint
access denied.That function exists but isn't available on the public API
usage limit reachedYou're out of usage tokens for the month. See Usage tokens
subscription expiredThe subscription behind this key has lapsed

access denied is deliberately vague and covers several cases:

  • A restricted table — account, billing, and internal tables are never readable
  • A read on a table that doesn't support it, or on any table other than organization and division from a free trial key
  • A create, update, or delete without write access
  • A query without query access

Request errors

ErrorWhat happened
missing classNo class in the request
missing functionNo function in the request
{class} class does not existCheck the spelling — the class is the table name
{function} is not a functionThat class has no such function
{argument} required.A required argument is missing. The message names it, e.g. organization_id required.
Arguments must be an object and not emptyarguments was empty, or wasn't an object
Something went wrong, please try again later.Something failed on our end — worth retrying

Errors still cost usage

A request that fails after it's been authorized — a bad argument, an unknown function — costs a minimum of 1 usage token, and the response carries the usual x-request-usage header.

Requests rejected for access reasons (no key, wrong key, no permission) cost nothing.

See Usage tokens for the details.

On this page