Tangocrypto
Search…
Pagination
Learn about pagination and how you can use it to manage large requests.

What is pagination?

Some API endpoints paginate their responses to make the result set easier to handle. For example, if you request a list of objects that are potentially too large to run efficiently, the endpoint returns the first batch of results along with a cursor to access the next set of results.
The query results are divided into "pages" of 1 MB in size (or less) data. An application can process the first page of results, then the second page, etc. You include the cursor in subsequent requests to the endpoint as a URL query parameter of your request.
To determine whether there are more results and to retrieve them one page at a time, applications should do the following:
  1. 1.
    Make a request with the desired size and check the result, if the cursor is not empty, construct a new request with the same parameters as the previous one. However, this time, take the cursor value from the last query and use it as the cursor parameter in the new request.
  2. 2.
    If the cursor is empty in the result it means there are no more items to be retrieved.

Example

Let's make the following query with size=50
1
https://cardano-mainnet.tangocrypto.com/<app-id>/v1/nft/collections?size=50
Copied!
In the response, we see the cursor with a non-empty value (showing only one record for simplicity)
1
{
2
"result": {
3
"collections": [
4
{
5
"id": "5f92c5e01c4848e4b6271a9bf48a3bd9",
6
"name": "Tango Collection",
7
"url": "https://www.tangocrypto.com",
8
"description": "Tango collection description",
9
"payout_address": "addr_test1qp9mj7vnenx4v99hw7ztfq03n7dmmujpgtlyfjhhel9w67nk72usllcew208n60ym94xcptfrgytuy5apwp565x28jgsg0ztq3",
10
"policy": {
11
"lock": true,
12
"lock_time": "2022-01-03T15:35:10.000Z",
13
"policy_id": "1373bf16cdea380e6c9c716d0f56f021b9e9ddea90b248dae6310d95",
14
"script": {
15
"type": "all",
16
"scripts": [
17
{
18
"type": "sig",
19
"keyHash": "ac1746df0ba039de81274d472a477fced610f57cebc5c7841074f54c"
20
},
21
{
22
"type": "before",
23
"slot": "46854826"
24
}
25
]
26
}
27
},
28
"metadata": {
29
"label": "721",
30
"asset_name": "<asset_name>",
31
"name": "<name>",
32
"image": "<image_link>",
33
"media_type": "<mime_type>",
34
"description": "<description>",
35
"attributes": {
36
"face": "<face>",
37
"twitter": "https://twitter.com/tango_crypto",
38
"copyright": "Tangocrypto 2021",
39
"color": "<color>",
40
"artist": "Tangocrypto",
41
"collection": "Tangocrypto Collection",
42
"body": "<body>",
43
"eyes": "<eyes>",
44
"accessory": "<accessory>"
45
},
46
"version": "1.0"
47
},
48
"created_at": "2021-11-30T21:04:09.897Z",
49
"updated_at": "2021-11-30T21:04:09.897Z"
50
}
51
],
52
"cursor": "a97f98a8c533ee55fc2c6897c9b50506dc8d65b921092e469f62f9d0e2d0dc92902605dba96d30b2e027557d3d6ea8cb3c1597d93e36f9c70771f19485f176607d834f6bc4fd664e0f68d4c28eff52cc298dee1dc17975c043d05903c31dae41ff84c779f1f8d2bcc00447e25d066a4e"
53
},
54
"status_code": 200
55
}
Copied!
To retrieve the next batch of items we use the same query but now inserting the obtained cursor from the previous step as a the query parameter:
1
https://cardano-mainnet.tangocrypto.com/<app-id>/v1/nft/collections?size=50&cursor=a97f98a8c533ee55fc2c6897c9b50506dc8d65b921092e469f62f9d0e2d0dc92902605dba96d30b2e027557d3d6ea8cb3c1597d93e36f9c70771f19485f176607d834f6bc4fd664e0f68d4c28eff52cc298dee1dc17975c043d05903c31dae41ff84c779f1f8d2bcc00447e25d066a4e
Copied!
This process can be repeated until the cursor is empty because there are no more items to retrieve.
Copy link