Skip to Content
Athanor

Budgets and headers

What a document costs, what a client may spend per hour, what every answer says about it, and what a 429 means.

A client has two budgets per hour: requests and complexity points. Every answer says where both stand. A spent budget is a 429, and the SDK waits it out on its own.

What a document costs

Cost is scored from the document before it runs, so a budget is spent in the same unit it is set in:

SelectedCost
A scalar or enum field0.1
An object or node field1, plus what is selected inside it
A list field1, plus per element it may return: 1 and what is selected inside
A connectionIts first sizes the edges and nodes lists inside it
A list without a sizeTaken as 50
A union or interfaceIts costliest member

So { viewer { __typename } } is 1.1, { products { id } } is 56, and a page of 10 orders with the full record is a few hundred points. Ask for what you will use, and say first.

Budgets

BudgetPer client, per hour
Requests1,500
Complexity points250,000

Windows are fixed hours. Sessions from the app itself are not budgeted; the API's own pages are.

Headers on every answer

X-Complexity: 23.1
X-RateLimit-Requests-Limit: 1500
X-RateLimit-Requests-Remaining: 1487
X-RateLimit-Requests-Reset: 2140
X-RateLimit-Complexity-Limit: 250000
X-RateLimit-Complexity-Remaining: 249104
X-RateLimit-Complexity-Reset: 2140

Reset is seconds until the window ends. A request that is refused still carries them.

A spent budget

HTTP/1.1 429 Too Many Requests
Retry-After: 2140
{
  "errors": [
    {
      "message": "The client's hourly budget is spent; the headers say when it refills.",
      "extensions": { "code": "RATELIMITED" }
    }
  ]
}

The SDK waits as Retry-After says, a minute at most, and tries again, three times at most. After that the 429 is the answer, an AthanorApiError with code: "RATELIMITED" and status: 429. If you are not on the SDK, do the same: never retry a 429 before Retry-After.

Staying well under

  • Webhooks over polling: a notice costs you nothing and arrives sooner than the next poll.
  • first on every connection, sized to what you render; nested lists above all.
  • One DealerContext at startup, cached; it does not change.
  • Read the record by id after a webhook rather than re-reading the feed.
  • Register your documents; a registered hash is the same cost but tells us what to expect.

See Being a good citizen.

On this page