Query Parameters

Prev Next

Starting from version 0.49, specific Rocket.Chat API endpoints support the following query parameters:

  • Pagination

Pagination

Pagination parameters allow you to control the number of results returned by an API request. The available parameters are listed below:

Parameter

Example

Description

Format

offset

50

The number of items to "skip" in the query. For example, a request returns count items after skipping the first offset items.

Positive integer

count

50

The number of items to return.

Integer

sort

{"value": -1, "_id": 1}

Defines the fields and direction for sorting results. Use 1 for ascending and -1 for descending order.

JSON object (key-value pairs for field and order)

Pagination parameter settings

To modify the behavior of the offset and count parameters, go to Manage → Workspace → Settings → General → REST API.

The following configuration options are available:

  • Default Count: The default number of results returned by REST API endpoints when the count parameter is not specified.

  • Max Record Amount: The maximum limit for the count parameter. If a higher value is provided, this limit will apply instead.

  • Allow Getting Everything: Enables the API to return all records when the count parameter is set to 0.

These settings give you fine-grained control over how data is paginated, sorted, and returned from Rocket.Chat API responses.

Example call

  • To retrieve a specific page of results with five items per page, use the count=5 and offset=10 query parameters in your API request:

GET http://localhost:3000/api/v1/channels.list?count=5&offset=10
  • To sort results by name in descending order and status in ascending order, use the sort parameter with a JSON object specifying field directions:

GET http://localhost:3000/api/v1/users.list?sort={"name":-1,"status":1}