Recent searches
No recent searches
Cannot use Search API with cursor-based Pagination
Posted Mar 16, 2022
I'm currently building a java client for Zendesk's Rest API and something doesn't work as expected.
Recently I've learned that when getting large datasets, Zendesk has introduced pagination. Among the two methods available, offset and cursor-based, it's recommended to use the latter and I'm doing so. For instance, when iterating over tickets or users, I make use of cursor based pagination.
However, cursor based pagination doesn't work with Search API. As long as official documentation says (https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/), within Result Limits, 'The Search API returns up to 1,000 results per query, with a maximum of 100 results per page. See Pagination.'. But when using my code, I get the following error:
"error": {
"title": "Invalid attribute",
"message": "You passed an invalid value for the page attribute. Invalid parameter: page must be an integer from api/v2/users/search"
}
0
3 comments
Christopher Kennedy
The benefits of cursor based pagination are greater with large data sets. But with the Search API, a given query will only return a maximum of 1,000 records - even if there are more than 1,000 matching records.
For queries that return more than 1,000 records, you may use the Export Search Results endpoint which supports cursor based pagination.
Best,
0
Jon I Sanchez Martinez
Thanks for your reply Christopher Kennedy
So, what's the difference between the classic Search and Export Search Results?
0
Christopher Kennedy
No problem - happy to clarify. The differences between the two endpoints revolve around their ability to handle large datasets.
The List Search Results endpoint is intended to return smaller result sets (up to 1,000). There's also a bit more flexibility as a single query can return matches to different object types (tickets, organizations, users, etc.)
The Export Search Results endpoint is intended to return larger result sets. A query will only return matches from one object type (specified in the request). This endpoint also has a rate limit of 100 requests per minute.
Best,
0