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.

Free Plan

  • 100 requests per hour
  • • 1 API key maximum
  • • 5 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: 1704456000
X-RateLimit-Reset-After: 3600

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 timestamp when the rate limit window resets
X-RateLimit-Reset-AfterSeconds until the rate limit 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
Retry-After: 3600

{
  "success": false,
  "error": "Rate limit exceeded. Try again in 3600 seconds."
}

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();
}