CometChat's REST API allows you to interact with the resources of the chat functionalities (users, messages, groups, etc).
It allows programmatic access to your data present in CometChat.
All API access is over HTTPS, and accessed from
All data is sent and received as JSON.
Note: The Chat API isn't designed for client side use. Use the Chat SDKs instead.
The API requests must be authenticated by the CometChat server using the
All API resources support bulk fetches via list API methods (for example, list all users).
These APIs support pagination through multiple query parameters.
- total is the number of total users in the application.
- count is the number of records in the data property.
- current_page is the value of page sent as query param, default=0.
- total_pages is the number of pages available. Thus the value of total page can be either equal to current_page or current_page+1.
- if total_pages == current_page there won't be any record on the next page
- if total_pages == current_page+1 we can request to fetch the next set of records.
To fetch the first page of 10 users, set the
perPage=10 as a query param.
This API will respond with a list of users. The response also has
meta object which has
cursor property in it. The cursor property denotes the identifier of the last user that was fetched in the current list.
To fetch the second page of 10 users (11 to 20), pass the
Note: The list messages API supports different pagination:
To fetch the first page of 10 messages, set the
limit=10 query param.
The response would have
metaobject which includes
current property in it.
So, to fetch the next set of results the properties present in the
next attribute would be passed in the query param for the subsequent request.
to fetch the previous set of results, the properties present in the
previous attribute would be passed in the query param for the subsequent request.
Tags are used for filtering the entities (users, groups, messages, etc).
It can be linked with any of the above entities so that it can be filtered.
A maximum of 25 tags can be associated with each entity.
Use Case: Let's say we want to display a discounted price only to premium users in the case of a food delivery app. In that case, we can add a tag as
premium to that user and then display the discounted price based on that tag.
Metadata is additional information that is stored so that it can be used.
There is no support for filtering in metadata.
It can store up to 1.6K characters (stringified JSON).
Use Case: Sharing location with users could include
longitude properties to be stored in metadata, so that it can be used for identifying the customer's location.