Skip to main content

Rate Limits

The TakeTheme API implements rate limiting to ensure fair usage and maintain service stability, you can only send 100 requests per minute, yet we can have custom limits on demand, feel free to email us at support@taketheme.com and a technical rep will be in touch.

Rate Limit Headers

Every API response includes rate limit information in the headers:

HTTP/1.1 200 OK
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1735693261
X-RateLimit-Bucket: default
HeaderDescription
X-RateLimit-LimitMaximum requests allowed per window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets
X-RateLimit-BucketThe rate limit bucket for this endpoint

Rate Limit Exceeded

When you exceed the rate limit, the API returns a 429 Too Many Requests response:

{
"message": "Rate limit exceeded",
"code": "RATE_LIMIT_EXCEEDED",
"status": 429
}

The response includes a Retry-After header indicating when you can retry:

HTTP/1.1 429 Too Many Requests
Retry-After: 45
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1735693333

Handling Rate Limits

Exponential Backoff

Implement exponential backoff for automatic retries:

async function fetchWithBackoff(url, options, maxRetries = 5) {
let delay = 1000; // Start with 1 second

for (let attempt = 0; attempt < maxRetries; attempt++) {
const response = await fetch(url, options);

if (response.status === 429) {
const retryAfter = response.headers.get("Retry-After");
const waitTime = retryAfter ? parseInt(retryAfter) * 1000 : delay;

console.log(`Rate limited. Waiting ${waitTime}ms before retry...`);
await new Promise((resolve) => setTimeout(resolve, waitTime));

delay *= 2; // Double the delay for next attempt
continue;
}

return response;
}

throw new Error("Max retries exceeded");
}

Python Implementation

import time
import requests
from functools import wraps

def retry_with_backoff(max_retries=5, base_delay=1):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
delay = base_delay
for attempt in range(max_retries):
response = func(*args, **kwargs)

if response.status_code == 429:
retry_after = int(response.headers.get('Retry-After', delay))
print(f"Rate limited. Waiting {retry_after}s...")
time.sleep(retry_after)
delay *= 2
continue

return response

raise Exception("Max retries exceeded")
return wrapper
return decorator

@retry_with_backoff(max_retries=5)
def get_products(api_key):
return requests.get(
'https://api.taketheme.com/api/v1/products',
headers={'tt-api-key': f'{api_key}'}
)

Proactive Rate Limiting

Monitor remaining requests and slow down before hitting limits:

class RateLimitedClient {
constructor(apiKey) {
this.apiKey = apiKey;
this.remaining = Infinity;
this.resetTime = 0;
}

async request(endpoint, options = {}) {
// Wait if we're close to the limit
if (this.remaining < 5) {
const waitTime = (this.resetTime - Date.now() / 1000) * 1000;
if (waitTime > 0) {
console.log(`Approaching rate limit. Waiting ${waitTime}ms...`);
await new Promise((resolve) => setTimeout(resolve, waitTime));
}
}

const response = await fetch(`https://api.taketheme.com/api/v1${endpoint}`, {
...options,
headers: {
tt-api-key: ` ${this.apiKey}`,
"Content-Type": "application/json",
...options.headers,
},
});

// Update rate limit tracking
this.remaining = parseInt(
response.headers.get("X-RateLimit-Remaining") || "0"
);
this.resetTime = parseInt(response.headers.get("X-RateLimit-Reset") || "0");

return response;
}
}

Requesting Higher Limits

If you need higher rate limits:

  1. Upgrade your plan — Higher tiers include increased limits
  2. Contact sales — For enterprise-level requirements, reach out to sales@taketheme.com
  3. Optimize your integration — Often, architectural changes can reduce the need for higher limits