Pagination
This guide will help you get started with fetching sequences of Alerts from the Alerts API
Depending on the use-case, there might be a need to fetch more than 100 entities from the Alerts API for local data processing. For such scenarios, Alerts API implements id-based cursor pagination.

Example

Let's assume we have the following set of Alerts available in the API:
1
[
2
{
3
"id": "05978d3a-0a49-8b63-b054-b65d37e4eb05"
4
},
5
{
6
"id": "9b8a3e5d-b7e5-0a67-7788-96d98349407b"
7
},
8
{
9
"id": "030bd54a-745b-9d6d-33d7-e683a0ee7389"
10
},
11
]
Copied!
Running the following GraphQL query would return the very first of the three Alerts:
1
query getAlerts {
2
alerts(first: 1) {
3
id
4
}
5
}
Copied!
1
[
2
{
3
"id": "05978d3a-0a49-8b63-b054-b65d37e4eb05"
4
},
5
]
Copied!
Since this response contains the same amount of items as was requested with the first argument, we can assume there are more Alerts available for the same query.
To fetch the next page, it's possible to specify after argument on the alerts node which accepts a valid Alert ID. It instructs the API to return all the entities following the one with the given ID.
Running the same query, but with after argument:
1
query getAlerts {
2
alerts(first: 1, after: "05978d3a-0a49-8b63-b054-b65d37e4eb05") {
3
id
4
}
5
}
Copied!
Will return the second Alert from the initial group.
1
[
2
{
3
"id": "9b8a3e5d-b7e5-0a67-7788-96d98349407b"
4
},
5
]
Copied!
after argument can be combined with any other arguments available on the alerts node, including orderBy
If we'll run the same query, using last Alert's ID, it'll return the empty array:
1
[]
Copied!
This indicates that we have paginated through all available entities and there are no more Alerts left.
Last modified 5mo ago
Copy link