Skip to content

Rate Limiting

To ensure fair usage and maintain system stability, Canteen’s Admin API enforces rate limits on requests. If you exceed these limits, your requests will be temporarily throttled.

Rate Limit Rules

The API applies the following rate limits per IP address and API token:

Endpoint ScopeLimitTime Window
General API Requests60 requestsper minute

Note: Rate limits may vary based on your organization type.

Handling Rate Limits

When you exceed the allowed number of requests, the API responds with HTTP 429 Too Many Requests:

Example Response

json
{
  "success": false,
  "message": "Too many requests. Please try again later."
}

Additionally, the API includes the following rate limit headers in every response:

HeaderDescription
X-RateLimit-LimitThe maximum number of requests allowed within the time window.
X-RateLimit-RemainingThe number of requests left before hitting the limit.
X-RateLimit-ResetThe timestamp (in seconds) when the limit resets.

Example Headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1707753600

Best Practices to Avoid Rate Limiting

To prevent hitting rate limits, follow these recommendations:

Optimize Requests: Cache responses where possible and avoid redundant API calls.
Use Webhooks: Instead of polling the API frequently, leverage webhooks for real-time updates.
Implement Retry Logic: If you receive a 429 Too Many Requests error, wait until the X-RateLimit-Reset time before retrying.
Batch Requests: If possible, send bulk requests instead of multiple small ones.

Handling Rate Limit Errors in Code

Example: Handling Rate Limits in JavaScript

js
  const response = await fetch(...);

  if (response.status === 429) {
    const resetTime = response.headers.get('X-RateLimit-Reset');
    console.warn(`Rate limit exceeded. Try again at ${new Date(resetTime * 1000)}`);
    return null;
  }

  return response.json();

Need Higher Limits?

TIP

If your application requires higher rate limits, contact our support team to discuss an upgrade plan.

This is a private API. All rights reserved.