⏱️Rate Limits

Our API employs rate limiting to ensure fair usage and to prevent abuse. Here are the details:

  • Rate Limit: 100 requests per minute.

  • Response Code for Exceeding Limit: 429 Too Many Requests

  • Retry-After Header: The response will include a Retry-After header indicating the number of seconds to wait before making further requests.

Handling Rate Limits

When your application exceeds the rate limit, it will receive a 429 Too Many Requests response. Here's how to handle this:

  1. Check for the 429 Status Code: When you receive a response, check if the status code is 429.

  2. Read the Retry-After Header: This header will tell you how many seconds to wait before retrying the request.

  3. Implement Retry Logic: Wait for the specified time and then retry the request.

Examples

Here are examples of how you can implement this logic in different programming languages:


const axios = require('axios');

async function makeApiRequest(url, options) {
    try {
        const response = await axios(url, options);
        return response.data;
    } catch (error) {
        if (error.response && error.response.status === 429) {
            // Extract the Retry-After header value
            const retryAfter = parseInt(error.response.headers['retry-after'], 10);

            if (!isNaN(retryAfter)) {
                console.log(`Rate limit exceeded. Retrying after ${retryAfter} seconds...`);
                await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
                return makeApiRequest(url, options); // Retry the request
            } else {
                console.error('Rate limit exceeded but no Retry-After header found.');
            }
        } else {
            console.error('Request failed:', error.message);
        }
    }
}

// Example usage
const url = 'https://api.example.com/your-endpoint';
const options = {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer your_token_here'
    }
};

makeApiRequest(url, options)
    .then(data => {
        console.log('API Response:', data);
    })
    .catch(error => {
        console.error('Request failed:', error.message);
    });
            

By implementing the above retry mechanism, your application can handle rate limiting gracefully, ensuring that your requests are processed once the rate limit resets. If you have any questions or need further assistance, please contact our support team at [email protected].

Last updated