Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

CometChat REST API Rate Limits

Rate limits are cumulative within each tier. For example, if you make 5,000 login requests and 5,000 create user requests in one minute, you’ve hit the 10,000 core operations limit.

Response Headers

CometChat includes rate limit information in response headers:
HeaderDescription
X-Rate-LimitYour current rate limit
X-Rate-Limit-RemainingRequests remaining in current window
Retry-AfterSeconds to wait before retrying (on 429)
X-Rate-Limit-ResetUnix timestamp when limit resets (on 429)

Handling Rate Limits

When you exceed the rate limit, CometChat returns HTTP 429 Too Many Requests. Implement exponential backoff to handle this gracefully:
async function callWithRetry<T>(
  apiCall: () => Promise<T>,
  maxRetries: number = 3
): Promise<T> {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await apiCall();
    } catch (error: any) {
      if (error.code === "TOO_MANY_REQUEST" && attempt < maxRetries - 1) {
        const waitTime = Math.pow(2, attempt) * 1000;
        console.log(`Rate limited. Retrying in ${waitTime / 1000}s...`);
        await new Promise((resolve) => setTimeout(resolve, waitTime));
      } else {
        throw error;
      }
    }
  }
  throw new Error("Max retries exceeded");
}

// Usage
const users: CometChat.User[] = await callWithRetry(() =>
new CometChat.UsersRequestBuilder().setLimit(30).build().fetchNext()
);

Tips for Staying Within Limits

  • Batch operations — Space out bulk operations over time instead of firing all at once
  • Monitor headers — Check X-Rate-Limit-Remaining to proactively slow down before hitting limits
  • Avoid frequent login/logout — Core operations share a lower limit; minimize login cycles
  • Use pagination — Fetch data in reasonable page sizes (30-50 items) rather than requesting everything at once
Rate limits can be adjusted based on your use case and plan. Contact CometChat support if you need higher limits.

Next Steps

Error Codes

Complete SDK error code reference

Best Practices

Recommended patterns including rate limit handling

Troubleshooting

Common issues and solutions

Key Concepts

Learn the core concepts behind CometChat