Pagination
In this guide, we will look at how to work with paginated responses when querying the Embed Notion Pages API. By default, all responses limit results to ten. However, you can go as high as 100 by adding a first
parameter to your requests.
When an API response returns a list of objects, no matter the amount, pagination is supported. In paginated responses, objects are nested in a data
attribute and have a has_next_page
attribute that indicates whether you have reached the end of the last page. You can use the after
query parameter to browse pages.
Example using cursors
In this example, we request the page that starts after the embed with id s4WycXedwhQrEFuM
. As a result, we get a list of three embeds and can tell by the has_next_page
attribute that we have reached the end of the resultset.
- Name
after
- Type
- string
- Description
The last ID on the page you're currently on when you want to fetch the next page.
- Name
first
- Type
- integer
- Description
Limit the number of items returned.
Manual pagination using cURL
curl -G https://api.embednotionpages.com/v1/embeds \
-H "Authorization: Bearer {token}" \
-d after="s4WycXedwhQrEFuM" \
-d first=10
Paginated response
{
"embeds": [
{
"id": "WAz8eIbvDR60rouK",
// ...
},
{
"id": "hSIhXBhNe8X1d8Et"
// ...
},
{
"id": "fbwYwpi9C2ybt6Yb"
// ...
}
],
"pagination": {
"total_count": 18,
"end_cursor": "fbwYwpi9C2ybt6Yb",
"has_next_page": true
}
}