Pagination
In this guide, we will look at how to work with paginated responses when querying the DUSAW API. When requesting a list of items, you can specify how many items you want to receive per page. The API will respond with a maximum of 1000 items per page, but you can request less. You can also request a specific page of items. If you do not specify a page number, the API will return the first page of results.
When an API response returns a list of objects, no matter the amount, pagination is supported. In paginated responses, objects are nested in a list
attribute and have a pageNo
, pageSize
, pages
& total
attributes.
Example
In this example, we request a list of locks that are currently active. We request 10 items per page and request the first page of results.
- Name
pageNo
- Type
- int
- Description
The page number of the results. Starts at 1.
- Name
pageSize
- Type
- int
- Description
How many items to return per page. The API will return a maximum of 1000 items per page.
Manual pagination using cURL
curl --location --request GET 'https://api.dusaw.com/api/v1/lock/list?pageNo=1&pageSize=10' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'
Paginated response
{
"list": [
...
{
"lockId": 865759,
"lockName":"DUS356_c15c7c",
"lockAlias":"Side Door Lock",
"lockMac": "C6:20:E6:9J:8W:Q6",
"electricQuantity": 86,
"featureValue":"3G0421S4Q5Q3",
"hasGateway": 1,
"lockData": "xxxxxxxxxxxxx",
"groupId": 789,
"groupName": "The Office",
"date": 1672689580361,
}
...
],
"pageNo":1,
"pageSize":10,
"pages":3,
"total":25
}