Adjustments to API rate limiting

Hey everyone :crystal_ball:

We made some changes to our rate limiting mechanism to make it easier for apps to understand their limits and prevent abuse of our API.

TLDR:

  • Each individual query now has a complexity limit of 5M
  • Most apps/users won’t notice a difference (but let us know if you do).

How our rate limits work: a recap

GraphQL rate limits are based on how much work you makes our servers do, measured in a unit called complexity. Each account and app has a specific complexity allowance that resets every minute. Trial accounts have a budget of 1M complexity every minute, while paid and developer accounts have a budget of 10M.

New error messages

When you run out of your complexity budget in a given minute, your app will now see a new error message that tells you how much budget you have left and when the limit resets:

"message": "Complexity budget exhausted, query cost 1100010 budget remaining 999819 out of 1000000 reset in 19 seconds"

Rate limit per query - 5M complexity

We are enforcing a new limit of 5M complexity for each individual query. This is still quite a high limit, and you should be able to comfortably write queries that are under this limit using pagination and other best practices (more on that below).

What should I do to prepare for this?

We believe that very few users will be affected by these changes. However, you can ensure you don’t hit these limits by making your queries as efficient as possible. Follow these simple rules:

  1. Don’t ask for more than what you need. Every field in your query contributes to its cost, so only return the data that your app needs to do its job.

  2. Paginate, paginate, paginate. As far as possible, paginate through the returned data using the page and limit parameters. If you don’t add a limit or pagination to your query, we’ll assume you’re trying to return 1000 data points (which could blow up your query’s complexity).

  3. Reduce deeply nested fields. Each level of nesting in your query increases its complexity by 10x. Therefore, minimize the complexity of your query by ensuring you are returning the majority of your data in the first or second level of nesting.

Here’s an example:

# Inefficient (cost: 1011020)
query {
  boards (ids:162169280) {
    groups {
      id
      items {
        id
      }
    }
  }
}

# Efficient (cost: 1220)
query {
  boards (ids:162169280) {
    items (limit:100) {
      id
      group {
        id 
      }
    }
  }
}

Have a question, comment, or feedback?

Create a new thread from this topic by clicking the link icon :link: at the bottom of the post, and hitting “New Topic”: