Skip to main content

Overview

The PricingSaaS Intelligence API implements rate limiting to ensure fair usage and maintain service quality for all users. Rate limits vary by subscription tier.

Rate Limit Tiers

100 requests per hour
  • Perfect for testing and small projects
  • Resets every hour
  • No credit card required

Rate Limit Headers

Every API response includes headers showing your current rate limit status:
HTTP/1.1 200 OK
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 987
X-RateLimit-Reset: 1640995200
X-RateLimit-Limit
integer
Maximum requests allowed in the current window
X-RateLimit-Remaining
integer
Number of requests remaining in the current window
X-RateLimit-Reset
integer
Unix timestamp when the rate limit resets

Reading Rate Limit Headers

const response = await fetch(
  'https://api.pricingsaas.com/functions/v1/api/companies',
  {
    headers: {
      'Authorization': `Bearer ${API_KEY}`
    }
  }
);

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}`);
console.log(`Resets at: ${new Date(reset * 1000)}`);

Rate Limit Exceeded

When you exceed your rate limit, the API returns a 429 Too Many Requests response:
{
  "error": "Rate limit exceeded",
  "message": "You have exceeded your rate limit of 100 requests per hour",
  "retry_after": 3600
}
Status Code: 429 Too Many RequestsHeaders:
  • Retry-After: Seconds until you can make requests again
  • X-RateLimit-Reset: Unix timestamp when limit resets

Handling Rate Limits

Exponential Backoff

Implement exponential backoff when you hit rate limits:
async function fetchWithRetry(url, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    const response = await fetch(url, {
      headers: { 'Authorization': `Bearer ${API_KEY}` }
    });

    if (response.status === 429) {
      const retryAfter = response.headers.get('Retry-After');
      const delay = retryAfter ? parseInt(retryAfter) * 1000 : Math.pow(2, i) * 1000;

      console.log(`Rate limited. Retrying in ${delay}ms`);
      await new Promise(resolve => setTimeout(resolve, delay));
      continue;
    }

    return response;
  }

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

Request Throttling

Proactively throttle your requests to stay under the limit:
class RateLimiter {
  constructor(maxRequests, windowMs) {
    this.maxRequests = maxRequests;
    this.windowMs = windowMs;
    this.requests = [];
  }

  async throttle() {
    const now = Date.now();
    this.requests = this.requests.filter(time => now - time < this.windowMs);

    if (this.requests.length >= this.maxRequests) {
      const oldestRequest = this.requests[0];
      const waitTime = this.windowMs - (now - oldestRequest);
      await new Promise(resolve => setTimeout(resolve, waitTime));
    }

    this.requests.push(now);
  }
}

// Usage: 100 requests per hour for free tier
const limiter = new RateLimiter(100, 60 * 60 * 1000);

async function fetchCompanies() {
  await limiter.throttle();
  return fetch('https://api.pricingsaas.com/functions/v1/api/companies', {
    headers: { 'Authorization': `Bearer ${API_KEY}` }
  });
}

Best Practices

Cache API responses to reduce redundant requests. Company data doesn’t change frequently.
const cache = new Map();

async function getCachedCompany(slug) {
  if (cache.has(slug)) {
    return cache.get(slug);
  }

  const response = await fetch(
    `https://api.pricingsaas.com/functions/v1/api/companies/${slug}`,
    { headers: { 'Authorization': `Bearer ${API_KEY}` } }
  );

  const data = await response.json();
  cache.set(slug, data);
  return data;
}
Use pagination to fetch multiple records in fewer requests:
# Instead of 10 requests for 10 companies:
curl "https://api.pricingsaas.com/functions/v1/api/companies?limit=10"

# More efficient than 10 individual requests
Track your rate limit usage in real-time:
const remaining = parseInt(response.headers.get('X-RateLimit-Remaining'));
const limit = parseInt(response.headers.get('X-RateLimit-Limit'));
const percentUsed = ((limit - remaining) / limit) * 100;

if (percentUsed > 80) {
  console.warn(`Warning: ${percentUsed.toFixed(1)}% of rate limit used`);
}
Use query parameters to filter results and reduce unnecessary data transfer:
# Get only what you need
curl "https://api.pricingsaas.com/functions/v1/api/companies?category=Communication&limit=5"
If you’re consistently hitting rate limits, consider upgrading to Pro tier for 10x capacity.

Rate Limit FAQs

No, rate limits use a sliding window. They reset exactly one hour after your first request in the current window.
Rate limits are per API key. If you have multiple keys, each has its own rate limit.
Your rate limit increases immediately upon upgrade. The reset timer remains the same.
No, only successful responses (2xx status codes) count toward your rate limit. 4xx and 5xx errors don’t count.
Enterprise customers can request temporary increases. Contact support with your use case.

Monitoring Your Usage

View your API usage in the dashboard:
  • Real-time usage: Current requests in the window
  • Historical trends: Daily and monthly usage graphs
  • Rate limit violations: When and why you hit limits
  • Usage forecasting: Predict when you’ll need to upgrade

View Usage Dashboard

Monitor your API usage and rate limits in real-time

Need Higher Limits?