Rate Limiting

Rate Limiting

In a GraphQL API each query is different depending on the information that is requested. For this reason instead of a traditional rate limiter we use a complexity limiter with a token bucket algorithm (opens in a new tab) for all our requests.

Main Parts

The complexity limiter consists of five main parts:

1. Maximum Available Credits

The maximum available credits that you can get.

2. Current Available Credits

The credits that you have available to do requests to the API.

3. Credit Restore Rate

The amount of credits that are added back into your available credits every second.

4. Current Query Credit Cost

The credit cost of the current query you are executing. This cost will be subtracted from your available credits.

5. Maximum Query Credit Cost

The maximum cost of a query you can do to our API.

What does this look like?

When you do a query to our API you will receive a response like this:

  "errors": ...,
  "data": ...,
  "extensions": {
    "cost": {
      "requestedQueryCost": 1500,
      "throttleStatus": {
        "maximumAvailable": 30000,
        "currentlyAvailable": 28500,
        "restoreRate": 500

The extensions object will have a cost field where you can see the cost of the query, the credits you still have available, the maximum credits you can have and the rate at which credits are restored.