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

  • • 100 requests per hour
  • • 1 API key
  • • 5 active Price & Time 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) {
  for (let attempt = 0; attempt <= 3; attempt++) {
    const response = await fetch(url, options);
    const body = await response.json();
    if (response.status !== 429) {
      if (!response.ok) throw new Error(body.error?.message || 'Request failed');
      return body;
    }
    if (attempt === 3) throw new Error('Rate limit retry budget exhausted');

    // Reset is a Unix timestamp in milliseconds, also supplied in 429 bodies.
    const reset = Number(response.headers.get('X-RateLimit-Reset')
      ?? body.error?.details?.rate_limit?.reset);
    const delay = Number.isFinite(reset) && reset > Date.now()
      ? reset - Date.now()
      : 1000 * 2 ** attempt;
    await new Promise(resolve => setTimeout(resolve, Math.max(1000, delay)));
  }
}