Skip to main content

API Documentation

Everything you need to integrate StockAlert.pro into your applications

Rate Limits

API usage limits and best practices for optimal performance

Overview

Rate limits help ensure fair usage and maintain API performance for all users. Different limits apply based on your subscription plan.

Basic Plan

  • API access: Not available
  • • 20 active alerts
  • • Email notifications only

Premium Plan

  • 10,000 requests per hour
  • • Unlimited API keys
  • • Unlimited alerts
  • • All notification channels

Rate Limit Headers

Every API response includes headers that show your current rate limit status:

HTTP/1.1 200 OK
X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1736180400000

Header Descriptions

HeaderDescription
X-RateLimit-LimitMaximum requests allowed in the current window
X-RateLimit-RemainingNumber of requests remaining in the current window
X-RateLimit-ResetUnix epoch time in milliseconds when the window resets

Handling Rate Limits

When You Hit the Limit

If you exceed your rate limit, you'll receive a 429 response:

HTTP/1.1 429 Too Many Requests
Content-Type: application/json

{
  "success": false,
  "error": {
    "code": "RATE_LIMITED",
    "message": "Too many requests",
    "details": {
      "rate_limit": {
        "limit": 200,
        "remaining": 0,
        "reset": 1736180400000
      }
    }
  }
}

Best Practices

  • Cache responses - Store frequently accessed data locally to reduce API calls
  • Implement exponential backoff - Gradually increase wait time between retries
  • Monitor rate limit headers - Track remaining requests to avoid hitting limits
  • Use webhooks - Receive real-time updates instead of polling

Example Implementation

Here's how to handle rate limits in your code:

async function makeApiRequest(url, options) {
  const response = await fetch(url, options);
  
  // Check rate limit headers
  const remaining = response.headers.get('X-RateLimit-Remaining');
  const resetAfter = response.headers.get('X-RateLimit-Reset-After');
  
  if (response.status === 429) {
    // Rate limited - wait and retry
    const retryAfter = parseInt(resetAfter) * 1000;
    console.log(`Rate limited. Retrying after ${retryAfter}ms`);
    
    await new Promise(resolve => setTimeout(resolve, retryAfter));
    return makeApiRequest(url, options); // Retry
  }
  
  // Log remaining requests
  console.log(`Requests remaining: ${remaining}`);
  
  return response.json();
}
Rate Limits - API Documentation | StockAlert.pro