This section will teach you how to paginate our collection endpoints
limit and offset
limit and offsetBy default, our getAll endpoints will accept limit and offset as query parameters.
| Query Params | Type | Default | Purpose |
|---|---|---|---|
limit | integer | 50 | Limit the number of results in the collection |
offset | integer | 0 | Specify the starting point of the collection |
Some examples using the List All Nationalities endpoint is given below.
Example 1: No limit and offset
limit and offset{
"data": [
{
"id": 1,
"name": "Afghan"
},
{
"id": 2,
"name": "Albanian"
},
{
"id": 3,
"name": "Algerian"
},
// ID 4-47 should come here (truncated for brevity)
{
"id": 48,
"name": "Czech"
},
{
"id": 49,
"name": "Danish"
},
{
"id": 50,
"name": "Djibouti"
}
],
"meta": {
"total": 193
},
"rels": []
}
Only 50 results have been returned from the endpoint since that is set by default. You can take a look at the meta object to identify the total number of elements in the collection.
"meta": {
"total": 193
},
Example 2: With limit=5
limit=5{
"data": [
{
"id": 1,
"name": "Afghan"
},
{
"id": 2,
"name": "Albanian"
},
{
"id": 3,
"name": "Algerian"
},
{
"id": 4,
"name": "American"
},
{
"id": 5,
"name": "Andorran"
}
],
"meta": {
"total": 193
},
"rels": []
}
Only the first 5 results have been returned. The meta object will still display the total number of elements.
You can set
limit=0to get the full collection!
Example 3: With limit=5 and offset=5
limit=5 and offset=5{
"data": [
{
"id": 6,
"name": "Angolan"
},
{
"id": 7,
"name": "Antiguans"
},
{
"id": 8,
"name": "Argentinean"
},
{
"id": 9,
"name": "Armenian"
},
{
"id": 10,
"name": "Australian"
}
],
"meta": {
"total": 193
},
"rels": []
}
Now the collection will start from the 6th record. You can change the offset without including the limit parameter as well.