Rate Limits
The Scompler API enforces rate limits and complexity limits per token to ensure platform stability.
Request limits
Limits are applied per token within a 5-minute window:
| Operation | Limit |
|---|---|
| Queries | 500 per 5 minutes |
| Mutations | 150 per 5 minutes |
Query complexity limits
Each request is also subject to node and complexity limits:
| Limit | Value |
|---|---|
| Query cost | 1,000 |
| Max nodes per request | 50,000 |
| Max nesting depth | 7 |
| Max aliases | 7 |
| Max directives | 20 |
| Max tokens | 1,000 |
Pagination
All list queries require either a first or last argument. Values must be between 1 and 100.
Navigation uses cursor-based pagination:
query {
languages(first: 10, after: $cursor) {
nodes {
id
name
}
pageInfo {
endCursor
startCursor
hasNextPage
hasPreviousPage
}
}
}
| Field | Description |
|---|---|
endCursor | Pass as after to fetch the next page |
startCursor | Pass as before to fetch the previous page |
hasNextPage | Whether more results exist after this page |
hasPreviousPage | Whether more results exist before this page |
Handling rate limit errors
When you exceed the limit, the API returns a RATE_LIMITED error:
{
"errors": [
{
"message": "Rate limit exceeded.",
"extensions": {
"code": "RATE_LIMITED"
}
}
]
}
Retry with backoff
async function queryWithRetry(query: string, variables = {}, maxRetries = 3) {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const response = await fetch('https://public-api.pro.scompler.com/graphql', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SCOMPLER_API_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ query, variables }),
})
const data = await response.json()
if (data.errors?.some((e) => e.extensions?.code === 'RATE_LIMITED')) {
if (attempt < maxRetries) {
await new Promise((r) => setTimeout(r, (attempt + 1) * 10_000))
continue
}
}
return data
}
}
tip
Use GraphQL field selection to request only the fields you need — this reduces query cost and helps you stay within complexity limits.