We have two rate limit tiers for the Rye API:

  • Default
  • Strict

You can check the following headers to track rate limits:

  1. Ratelimit-Limit: The maximum number of requests that the consumer is permitted to make in a given time window.
  2. Ratelimit-Remaining: The number of requests remaining in the current rate limit window.
  3. Ratelimit-Tier: The rate limit tier for the query or mutation. (Default or Strict)
  4. 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 default rate limit is 100 reqs/sec.

The following queries and mutations are in the Strict tier and have a rate limit of 1 req/sec:

  1. createCart
  2. submitCart
  3. requestProductByUrl
  4. requestStoreByUrl
  5. requestAmazonProductByUrl
  6. requestShopifyProductByUrl

If you need a higher rate limit, please contact us at dev@rye.com.