We have four rate limit tiers for the Rye API:
Default
- 100 requests/sec
Moderate
- 20 requests/sec
Elevated
- 5 requests/sec
Strict
- 1 request/sec
You can check the following headers to track rate limits:
Ratelimit-Limit
: The maximum number of requests that the consumer is permitted to make in a given time window.
Ratelimit-Remaining
: The number of requests remaining in the current rate limit window.
Ratelimit-Tier
: The rate limit tier for the query or mutation. (Default
, Strict
, Elevated
, Moderate
)
Ratelimit-Reset
: The time at which the current rate limit window resets in seconds.
Rate limit handling in your code
async function makeRateLimitedRequest(url) {
try {
const response = await axios.get(url);
// Extract rate limit headers
const rateLimit = parseInt(response.headers['ratelimit-limit'], 10);
const rateLimitRemaining = parseInt(response.headers['ratelimit-remaining'], 10);
const rateLimitReset = parseInt(response.headers['ratelimit-reset'], 10) * 1000; // Convert to milliseconds
if (rateLimitRemaining === 0) {
// If no requests are left, wait until the reset time
const waitTime = rateLimitReset - Date.now();
console.log(`Rate limit hit. Waiting ${waitTime} ms...`);
await delay(waitTime);
}
// Return the response data
return response.data;
} catch (error) {
console.error('Error making request:', error);
throw error;
}
}
// Usage
async function main() {
const url = 'https://api.example.com/your-endpoint';
try {
const data = await makeRateLimitedRequest(url);
console.log('Response data:', data);
} catch (error) {
console.error('Failed to retrieve data:', error);
}
}
main();
The following queries and mutations are in the Strict
tier
- createCart
- submitCart
- requestProductByUrl
- requestStoreByUrl
- requestAmazonProductByUrl
- requestShopifyProductByUrl
If you need a higher rate limit for strict tier, please contact us.
The following queries are in the Elevated
tier
- productByID
- productsByIds
Elevated tier’s rate limit can not be increased.