Pagination
In this guide, we will look at how to work with paginated responses when querying the LetsGo API. By default, there is no response limit. However, the user can add limit by adding limit parameter to your requests.
When an API response returns a list of objects, on some endpoints pagination is supported.
Example using cursors
In this example, we request the page 2 limit 4 from the /products endpoint. As a result, we get the second set of four prodcuts.
- Name
page- Type
- int
- Description
The page of the products returned.
- Name
limit- Type
- int
- Description
The limit the number of products returned.
Manual pagination using cURL
curl -G https://lets-go-phi.vercel.app/products \
-d page=2 \
-d limit=4
Paginated response
{
"total": 36,
"page": 2,
"limit": 4,
"category": [
"Star Wars",
"Disney",
//...
],
"products": [
{
"_id": "6633e6525fec9229af0bab5e",
"name": "Lego NINJAGO® City Markets",
//...
},
{
"_id": "662eb3f04341bfa0b2d43ea3",
"name": "LEGO Star Wars AT-AT™",
//...
},
{
"_id": "663123e86a07b082680ec524",
"name": "LEGO® Star Wars™ - Venator-class Republic Attack Cruiser",
//...
},
{
"_id": "6633e6535fec9229af0bab60",
"name": "Millennium Falcon™",
//...
}
]
}