Skip to content

Pagination

Leads2b provides pagination for most item listing endpoints in our API.

Cursor-based Pagination

Our pagination is implemented using a cursor, which is simply an identifier used to navigate through pages of results. The cursor is returned in the API response and must be used in the next request to retrieve the next page.

Endpoints that use cursor-based pagination return an object with the fields size, next_cursor, and data. The size field indicates the number of records returned on the current page, and next_cursor is the cursor that should be used in the next request. To fetch the next page of results, include the next_cursor value from the previous response in the cursor parameter, along with the limit parameter, which specifies the number of records per page. This ensures sequential navigation.

Pagination Example

Initial Request

To retrieve the first set of results, make a request to the desired endpoint without the cursor parameter:

http
GET /items?limit=3

Response

The API will return a JSON object containing the current page data and the next_cursor for the next request:

json
{
  "size": 3,
  "next_cursor": "dyz",
  "data": [
    { "id": "ayz", "name": "Item A" },
    { "id": "byz", "name": "Item B" },
    { "id": "cyz", "name": "Item C" }
  ]
}

Next Page

To fetch the next page of results, use the next_cursor value from the previous response:

http
GET /items?limit=3&cursor=dyz

Next Page Response

json
{
  "data": [
    { "id": "dyz", "name": "Item D" },
    { "id": "eyz", "name": "Item E" },
    { "id": "fyz", "name": "Item F" }
  ],
  "size": 3,
  "next_cursor": "gyz"
}

This process can be repeated until the API returns next_cursor: null, indicating that there are no more results available.