Pagination
In this guide, we will look at how to work with paginated responses when querying the LSP.expert API.
All top-level API resources have support for bulk fetches through “list” API methods. For example, you can list jobs, list clients, and list invoices. These list API methods share a common structure and accept, at a minimum, the following parameters: page
, sort
, direction
.
Search request format
pagenumber
The page number to fetch. The first page is 1. If not provided, the default is 1.
sortstring
The field to sort by. Each resource may support different sort options. If not provided, the default is the resource's default sort order.
directioninteger
The direction to sort by:
asc
ordesc
. If not provided, the default is the resource's default sort direction.
Search response format
itemsarray
The list of items.
pageSizenumber
The number of items per page.
pagenumber
The current page number.
totalPagesnumber
The total number of pages.
totalItemsnumber
The total number of items.
hasNextPageboolean
Indicates whether there is a next page.
hasPreviousPageboolean
Indicates whether there is a previous page.
Manual pagination using cURL
curl -G https://api.lsp.expert/v2/jobs \
-u {key}: \
-d page=2
Paginated response
{
"items": [
{
"id": "WAz8eIbvDR60rouK",
// ...
},
{
"id": "hSIhXBhNe8X1d8Et"
// ...
},
{
"id": "fbwYwpi9C2ybt6Yb"
// ...
}
],
"pageSize":20,
"page":2,
"totalPages":10,
"totalItems":198,
"hasNextPage":true,
"hasPreviousPage":true
}