HomeDocumentation

Rate Limiting

To ensure consistent performance and fair resource allocation for all Telesoft API users, we implement rate limiting across our API endpoints. Understanding these limits will help you optimize your application's integration with our services.

Overview

Rate limits in the Telesoft API are applied on a per-key basis, with different tiers having different limits. These limits are tracked using a sliding window algorithm that counts the number of requests you make in a specific time period.

Rate Limit Headers

Every API response includes headers that provide information about your current rate limit status:

HeaderDescription
X-RateLimit-LimitThe maximum number of requests allowed in the current time window
X-RateLimit-RemainingThe number of requests remaining in the current time window
X-RateLimit-ResetThe time at which the current rate limit window resets in UTC epoch seconds
Retry-AfterOnly present when rate limited. The number of seconds to wait before retrying

Rate Limit Categories

Different API endpoints have different rate limits based on their computational intensity and resource requirements.

Standard Endpoints

Standard endpoints include basic operations such as retrieving, updating, or deleting resources.

PlanRate Limit
Developer100 requests per minute
Professional300 requests per minute
Enterprise1,000 requests per minute

AI Diagnostic Endpoints

AI diagnostic endpoints perform complex medical analysis and require more computational resources.

PlanRate Limit
Developer20 requests per minute
Professional50 requests per minute
Enterprise200 requests per minute

Bulk Operations

Bulk operations handle multiple records in a single request and have special rate limiting rules.

PlanRate Limit
Developer5 requests per minute (max 100 items per request)
Professional15 requests per minute (max 500 items per request)
Enterprise30 requests per minute (max 1,000 items per request)

Endpoint-Specific Limits

Some endpoints have specific rate limits due to their specialized nature or resource requirements.

EndpointDescriptionRate Limit
/v1/diagnostics/differentialGenerates differential diagnoses based on symptoms10 requests per minute (all plans)
/v1/diagnostics/image-analysisAnalyzes medical images for anomalies5 requests per minute (all plans)
/v1/knowledge/drug-interactionsChecks for potential drug interactions30 requests per minute (all plans)
/v1/patients/batch-updateUpdates multiple patient recordsSee Bulk Operations

Handling Rate Limiting

Recommended Approach

When your application receives a rate limit error (HTTP 429), follow these best practices:

  1. Respect the Retry-After header, which tells you how long to wait before retrying.
  2. Implement exponential backoff with jitter when retrying to avoid creating sudden spikes in traffic.
  3. Consider caching responses where appropriate to reduce the number of API calls.
  4. Monitor the X-RateLimit-Remaining header to adjust your request patterns before hitting limits.

Example: Handling Rate Limiting with Exponential Backoff

import { TelesoftAI, TelesoftAPIError } from '@telesoft/healthcare-sdk';

// Configure the SDK
const telesoft = new TelesoftAI({
  apiKey: 'YOUR_API_KEY',
  environment: 'production'
});

// Retry function with exponential backoff
async function retryWithBackoff(fn, maxRetries = 5) {
  let retries = 0;
  
  while (true) {
    try {
      return await fn();
    } catch (error) {
      if (!(error instanceof TelesoftAPIError) || 
          error.status !== 429 || 
          retries >= maxRetries) {
        throw error; // Not a rate limit error or max retries exceeded
      }
      
      retries++;
      
      // Get retry time from header or calculate with exponential backoff
      let retryAfterSeconds;
      if (error.headers && error.headers['retry-after']) {
        retryAfterSeconds = parseInt(error.headers['retry-after'], 10);
      } else {
        // Exponential backoff with jitter: 2^retries * 100ms + random jitter
        const baseDelay = Math.pow(2, retries) * 100;
        const jitter = Math.random() * 100;
        retryAfterSeconds = (baseDelay + jitter) / 1000;
      }
      
      console.log(`Rate limited. Retrying in ${retryAfterSeconds} seconds. Attempt ${retries} of ${maxRetries}`);
      
      // Wait before retrying
      await new Promise(resolve => setTimeout(resolve, retryAfterSeconds * 1000));
    }
  }
}

// Example usage
async function getDifferentialDiagnosis(symptoms) {
  return retryWithBackoff(async () => {
    return await telesoft.diagnostics.getDifferential({
      symptoms,
      patientInfo: {
        age: 35,
        sex: 'female'
      }
    });
  });
}

// Call the function
getDifferentialDiagnosis(['fever', 'cough', 'fatigue'])
  .then(result => console.log('Diagnosis:', result))
  .catch(error => console.error('Error:', error));

Concurrent Request Limits

In addition to rate limits based on requests per minute, we also limit the number of concurrent requests that can be made with a single API key.

PlanConcurrent Request Limit
Developer5 concurrent requests
Professional20 concurrent requests
Enterprise50 concurrent requests

⚠️ Note

Exceeding concurrent request limits will result in a 429 error with a specific error code of concurrent_request_limit. Your application should manage parallel requests to stay within these limits.

Rate Limit Exemptions

Enterprise customers may request rate limit exemptions for specific use cases or during planned high-traffic events.

  • To request a temporary rate limit increase, contact your account manager at least 48 hours in advance.
  • Provide details about the expected traffic pattern, duration, and business justification.
  • For permanent rate limit increases, please contact sales to discuss upgrading your plan.

💡 Pro Tip

If you're consistently hitting rate limits, consider using our bulk API endpoints where available. For example, instead of making 100 separate patient update requests, you can use the /v1/patients/batch-update endpoint to update multiple patients in a single request.