Pagination
In this guide, we will look at how to work with paginated responses when querying the typeauth API. By default, all responses limit results to 100. However, you can go as high as 1000 by adding a limit
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_more
attribute that indicates whether you have reached the end of the last page. You can use the starting_after
and endding_before
query parameters to browse pages.
Example using cursors
In this example, we request the page that starts after the application with id 0000111122222
. As a result, we get a list of three applications and can tell by the has_more
attribute that we have reached the end of the resultset.
- Name
starting_after
- Type
- string
- Description
The last ID on the page you're currently on when you want to fetch the next page.
- Name
ending_before
- Type
- string
- Description
The first ID on the page you're currently on when you want to fetch the previous page.
- Name
limit
- Type
- integer
- Description
Limit the number of items returned.
Manual pagination using cURL
curl -G https://api.typeauth.com/:accountID/application?limit=500 \
-H "Authorization: Bearer {token}" \
Paginated response
{
"success" : true,
"message": "",
"data": [
{
"accId": "KFUEB2_W5SaQ754BUKz4r",
"id": "H-N2eFoWSFN8CGZhFuYGi",
"name": "K8S API",
"description": "desc",
"createdAt": "2024-04-13T02:52:08.470Z",
"updatedAt": "2024-04-13T02:52:08.470Z",
"prefix": "k8s_",
"keyCount": 100
},
{
"accId": "KFUEB2_W5SaQ754BUKz4r",
"id": "CRK6liE5URUCBkK5nVUDn",
"name": "GCP APP",
"description": "GCP application",
"createdAt": "2024-04-13T23:08:35.992Z",
"updatedAt": "2024-04-13T23:08:35.992Z",
"prefix": "gcp_",
"keyCount": 50
},
{
"accId": "KFUEB2_W5SaQ754BUKz4r",
"id": "I_67e4gMC1RdBGedMdSXW",
"name": "AWS GW",
"description": "AWS gateway API",
"createdAt": "2024-04-13T23:08:41.520Z",
"updatedAt": "2024-04-13T23:08:41.520Z",
"prefix": "aws_",
"keyCount": 13
},
]
"has_more": false,
}