Skip to main content

Overview

The DNSRadar API implements rate limiting to ensure fair usage and maintain service quality for all users. Rate limits are applied per API key and reset at fixed intervals.
All rate limits use a sliding window algorithm, meaning limits reset continuously rather than at fixed intervals.

Rate Limit Tiers

Standard Endpoints

Most API endpoints follow these rate limits:

Read Operations

20 requests per minuteApplies to all GET requests

Write Operations

5 requests per minuteApplies to POST, PUT, PATCH, and DELETE requests

Bulk Import Endpoints

The following endpoints have higher limits to support bulk operations:

Monitor Creation

250 requests per minuteApplies to:
  • POST /monitors
  • POST /monitors/bulk
The POST /monitors/bulk endpoint accepts up to 1,000 monitors per request, allowing you to theoretically import 250,000 monitors per minute when used efficiently.

Rate Limit Headers

Every API response includes headers that provide information about your current rate limit status:
X-RateLimit-Limit
integer
The maximum number of requests you can make per minute for this endpointExample: 20
X-RateLimit-Remaining
integer
The number of requests remaining in the current rate limit windowExample: 15
X-RateLimit-Reset
integer
Unix timestamp (in seconds) indicating when the rate limit window resetsExample: 1704636000

Example Response Headers

HTTP/1.1 200 OK
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 15
X-RateLimit-Reset: 1704636000
Content-Type: application/json

Handling Rate Limits

Rate Limit Exceeded Response

When you exceed the rate limit, you’ll receive a 429 Too Many Requests response:
{
  "code": 429,
  "error": "Rate limit exceeded. Please try again in 45 seconds."
}

Best Practices

Always check the X-RateLimit-Remaining header and proactively slow down requests before hitting the limit.
const remaining = parseInt(response.headers.get('X-RateLimit-Remaining'));

if (remaining < 3) {
  console.warn('Approaching rate limit. Slowing down requests...');
  await sleep(5000); // Wait 5 seconds
}
When you receive a 429 response, wait before retrying with increasing delays between attempts.
async function fetchWithRetry(url, options, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    const response = await fetch(url, options);

    if (response.status !== 429) {
      return response;
    }

    const resetTime = parseInt(response.headers.get('X-RateLimit-Reset'));
    const waitTime = (resetTime * 1000) - Date.now();

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

  throw new Error('Max retries exceeded');
}
When creating multiple monitors, use the POST /monitors/bulk endpoint instead of making individual requests.Instead of this:
// 1000 requests = exceeds rate limit
for (const monitor of monitors) {
  await createMonitor(monitor);
}
Do this:
// 1 request = efficient
await createMonitorsBulk(monitors); // up to 1000 at once
Cache responses from GET requests when appropriate to reduce unnecessary API calls.
const cache = new Map();
const CACHE_TTL = 60000; // 1 minute

async function getCachedMonitors() {
  const cached = cache.get('monitors');

  if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
    return cached.data;
  }

  const data = await fetchMonitors();
  cache.set('monitors', { data, timestamp: Date.now() });
  return data;
}
Instead of sending bursts of requests, distribute them evenly across the rate limit window.
// Spread 20 requests over 60 seconds (1 per 3 seconds)
const delayBetweenRequests = 60000 / 20; // 3000ms

for (const item of items) {
  await processItem(item);
  await sleep(delayBetweenRequests);
}

Rate Limit Examples

Checking Rate Limit Status

const response = await fetch('https://api.dnsradar.dev/monitors', {
  headers: { 'X-Api-Key': apiKey }
});

const limit = response.headers.get('X-RateLimit-Limit');
const remaining = response.headers.get('X-RateLimit-Remaining');
const reset = response.headers.get('X-RateLimit-Reset');

console.log(`Rate Limit: ${remaining}/${limit} requests remaining`);
console.log(`Resets at: ${new Date(reset * 1000).toISOString()}`);
Need higher rate limits? Contact our sales team to discuss enterprise plans with custom rate limits.