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.

  • Core Operations (login, create/delete user, create/join group): 10,000 requests/min cumulative
  • Standard Operations (all other): 20,000 requests/min cumulative
  • Rate-limited responses return HTTP 429 with Retry-After and X-Rate-Limit-Reset headers
  • Monitor usage via X-Rate-Limit and X-Rate-Limit-Remaining response headers
CometChat applies rate limits to REST API requests to ensure fair usage and platform stability. SDK methods that call the REST API under the hood (like fetching users, sending messages, or creating groups) are subject to these limits. Understanding them helps you build applications that handle high traffic gracefully.

Rate Limit Tiers

Operation TypeLimitExamples
Core Operations10,000 requests/minLogin, create/delete user, create/join group
Standard Operations20,000 requests/minAll other operations
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

Key Concepts

Review the fundamental building blocks of CometChat

Setup & Authentication

Initialize CometChat and authenticate users in your app

Real-Time Listeners

Complete reference for all SDK event listeners

Connection Status

Monitor SDK connection state changes