Paginating Results

Pagination in the API is handled via the Link header standard:

Copied
curl -i https://sentry.io/api/0/projects/1/groups/

When supported, cursors will always be returned for both a previous and a next page, even if there are no results on these pages. This allows you to make a query against the API for yet-undiscovered results. An example where this would be used is when you’re implementing polling behavior and you want to see if there is any new data. We return a results="[true|false]" indicator to determine if you actually need to paginate.

Pagination Example

Here is a pagination example using this API endpoint:

https://docs.sentry.io/api/events/list-an-issues-events/

The HTTP request in this example returns 100 events for the issue and has the following link header in the response:

Copied
<https://sentry.io/api/0/issues/123456/events/?&cursor=0:0:1>; rel="previous"; results="false"; cursor="0:0:1", <https://sentry.io/api/0/issues/123456/events/?&cursor=0:100:0>; rel="next"; results="true"; cursor="0:100:0"

One of the URLs in the link response has rel=next, which indicates the next results page. It also has results=true, which means that there are more results.

Based on this, the next request is GET <https://sentry.io/api/0/issues/123456/events/?&cursor=0:100:0>.

This request will return the next 100 events for that issue, again, with the following link header:

Copied
<https://sentry.io/api/0/issues/123456/events/?&cursor=0:0:1>; rel="previous"; results="true"; cursor="0:0:1", <https://sentry.io/api/0/issues/123456/events/?&cursor=0:200:0>; rel="next"; results="true"; cursor="0:200:0"

The process is repeated until the URL with rel=next has the flag results=false to indicate the last page.

The three values from cursor are: cursor identifier (integer, usually 0), row offset, and is_prev (1 or 0).