Pagination

In this guide, we will look at how to work with paginated responses when querying the Underdog API.

By default, all responses limit results to ten. However, you can go as high as 100 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 results attribute and include four attributes to determine whether you have reach the end of the last page.

  • limit

  • page

  • totalPages

  • totalResults

You can use the limit and page query parameters to browse pages.

Example using cursors

In this example, we request the first page with at most one result. As a result, we get a list of one Collection and can tell by the totalResults and totalPages attributes that we have one more page of results.

limit integer

Limit the number of items returned.

page integer

The page number to return.

Manual pagination using cURL
curl "https://api.underdogprotocol.com/v1/collections?limit=1&page=1" \
        -H "Authorization: Bearer {token}"
Paginated response
{
    "results":[{
        "mintAddress":"FrvZAJ1qZ2vhV17nFdEmw66N3FW5QiHFt6HdqsEh8QNq",
        "name":"NBA",
        "description":"",
        "image":"https://arweave.net/57PrJ_-S-m2BXOSkaUN2t5ibsjbSrCjElSVUQXXyCq0",
        "attributes":[],
        "uri":"https://arweave.net/DnftYIM2sNZQBXm7qzRiFoUP0S7QtN4q_GkmIcv1UJ8",
        "collectionDetails":{},
        "ownerAddress":"EBeLw5jEdrEgDe17BdKGW2MizzGxtxigEuAGvYC7VzDp"
    }],
    "page": 1,
    "limit": 1,
    "totalPages": 1,
    "totalResults": 2
}

Last updated