Pagination
In this guide, we will explore how to handle paginated responses when querying the Gravity API.
When an endpoint returns a paginated response, you will need to use the page
parameter to specify the page number you wish to retrieve.
Additionally, a limit
parameter can be used to determine the number of records per page. By default, the limit
is set to 50 records per page.
You can specify one of the following values for the limit
parameter: 5, 10, 20, 50, or 100 records per page.
The page numbers start at 1. If additional pages are available, the response will include a meta
object with boolean flag hasMore
set to true
. You can then increment the page
number to retrieve subsequent pages of records.
Example: Paginated Request
curl -X GET 'https://api.sandbox.gravity.markets/v1/ledger?page=1&limit=10" \
-H 'Authorization : Bearer <token>'
Example Response
JSON
200 OK{
"entries": [
{
"createdAt": "2024-03-06T06:52:23.910Z",
"updatedAt": "2024-03-06T06:52:23.910Z",
"entryId": "24f2a201-9a51-49df-a9fd-bca00016bcd4",
"correspondentId": "001039fe-bc64-4aa1-98db-8281596c2f8e",
"accountType": "ASSET",
"transactionType": "TRANSFER",
"type": "CREDIT",
"amount": 25.25,
"status": "COMPLETED",
"symbol": "CASH"
},
{
"createdAt": "2024-03-06T07:01:42.944Z",
"updatedAt": "2024-03-06T07:01:42.944Z",
"entryId": "4b02e134-ec4d-4a49-860b-4028433143e4",
"correspondentId": "001039fe-bc64-4aa1-98db-8281596c2f8e",
"accountType": "ASSET",
"transactionType": "TRANSFER",
"type": "DEBIT",
"amount": 900,
"status": "COMPLETED",
"symbol": "CASH"
},
{
"createdAt": "2024-03-06T07:01:43.109Z",
"updatedAt": "2024-03-06T07:01:43.109Z",
"entryId": "7bbe032f-3805-483c-8442-e36103ece4e8",
"correspondentId": "001039fe-bc64-4aa1-98db-8281596c2f8e",
"accountType": "LIABILITY",
"transactionType": "TRANSFER",
"type": "CREDIT",
"amount": 900,
"status": "COMPLETED",
"symbol": "CASH"
},
{
"createdAt": "2024-03-10T00:59:51.614Z",
"updatedAt": "2024-03-10T00:59:51.614Z",
"entryId": "35bae534-6fc7-4699-9f73-3a0997b4db96",
"correspondentId": "001039fe-bc64-4aa1-98db-8281596c2f8e",
"accountType": "ASSET",
"transactionType": "TRANSFER",
"type": "CREDIT",
"amount": 1.5,
"status": "COMPLETED",
"symbol": "CASH"
},
{
"createdAt": "2024-03-10T00:59:51.771Z",
"updatedAt": "2024-03-10T00:59:51.771Z",
"entryId": "44710fb6-0543-461d-9c1e-ae9ce743d511",
"correspondentId": "001039fe-bc64-4aa1-98db-8281596c2f8e",
"accountType": "LIABILITY",
"transactionType": "TRANSFER",
"type": "DEBIT",
"amount": 1.5,
"status": "COMPLETED",
"symbol": "CASH"
}
],
"meta": {
"page": 1,
"limit": 5,
"total": 22,
"hasMore": true
}
}