Rate limits
The Content API limits how much work your requests can do, to protect Swapcard servers from excessive or abusive calls. Check these limits before you run bulk imports or exports.
With GraphQL, one call can replace many REST calls: a single complex query can do the work of thousands of REST requests. The Content API therefore applies two kinds of limits:
- A cost-based limit: a budget of points you can spend per minute.
- Query limits: the maximum cost, depth and size of a single query.
Cost-based limit
The Content API gives each query a cost in points, based on its complexity (see how cost is calculated). By default, you can spend 60,000 points per minute.
Every API response includes headers that show your current usage:
| Header | Description |
|---|---|
X-RateLimit-Cost | The number of points the query cost. |
X-RateLimit-Used | The number of points you have used in the current rate limit window. |
X-RateLimit-Remaining | The number of points remaining in the current rate limit window. |
X-RateLimit-Limit | The maximum number of points you can use per window. |
X-RateLimit-Reset | The time at which the current window resets, in UTC epoch seconds. |
During bulk jobs, read X-RateLimit-Remaining on each response and pause until X-RateLimit-Reset when it runs low.
Query limits
Each query must stay within the following limits:
| Limit | Maximum | Notes |
|---|---|---|
| Cost | 10,000 points | A mutation costs 1,000 points, an object 2 points and a scalar 1 point. A depth factor of 1.5x is applied. |
| Depth | 20 levels | Levels of nested objects. |
| Aliases | 50 aliases | |
| Tokens | 2,000 tokens | A token is a field, an argument or an alias. |
| Directives | 20 directives |
Additional limits
- The request body must not exceed
1megabyte.
Request higher limits
If your integration needs different limits, submit a request with details about your queries and use case.
To guarantee service and prevent abuse, Swapcard may temporarily change the rate limit for some users without notice.