Skip to content

Commit a4155a2

Browse files
t-h-manimatwawana
andauthored
docs: Add API pagination example (#4244)
* docs: Add API pagination example * Apply suggestions from code review Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> * Update src/api/pagination.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> * Update src/api/pagination.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
1 parent 0d4426d commit a4155a2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/api/pagination.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,27 @@ Link: <https://sentry.io/api/0/projects/1/groups/?&cursor=1420837590:0:1>;
2222
```
2323

2424
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.
25+
26+
## Pagination Example
27+
28+
Here is a pagination example using this API endpoint:
29+
30+
https://docs.sentry.io/api/events/list-an-issues-events/
31+
32+
The HTTP request in this example returns 100 events for the issue and has the following link header in the response:
33+
```discover {tabTitle:Http}
34+
<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"
35+
```
36+
37+
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.
38+
39+
Based on this, the next request is `GET <https://sentry.io/api/0/issues/123456/events/?&cursor=0:100:0>`.
40+
41+
This request will return the next 100 events for that issue, again, with the following link header:
42+
```discover {tabTitle:Http}
43+
<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"
44+
```
45+
46+
The process is repeated until the URL with `rel=next` has the flag `results=false` to indicate the last page.
47+
48+
The three values from cursor are: cursor identifier (integer, usually 0), row offset, and is_prev (1 or 0).

0 commit comments

Comments
 (0)