Pagination

In this guide, we will explore how to handle paginated responses when querying the Lanewise API. By default, responses limit results to ten, but you can increase this limit to a maximum of 100 by adding a limit parameter to your requests. If you are using one of the official Lanewise API client libraries, you don't need to worry about pagination, as it is managed automatically.

Cursor Pagination

When an API response returns a list of objects, regardless of the number, pagination is supported. In paginated responses, objects are nested within a data attribute and include a next attribute that indicates whether you have reached the last page by either returning null or a cursor to fetch the next page. You can use the cursor query parameters to navigate through pages.

First Page

In this example, we request the first page. As a result, we get a list of two POIs and can tell by the next attribute that we have more results available.

  • Name
    limit
    Type
    integer
    Description

    Limit the number of items returned. Default it 15.

Cursor pagination using cURL

curl -G https://api.lanewise.app/v1/pois \
  -H "X-API-KEY: {YOUR_API_KEY}" \
  -d limit=2

Paginated response

{
  "data": [
    {
      "id": "01J42GFDYE5Q8QD42ZS3ZEV751",
      "test": 1.1,
      "test2": null,

      // ...
    },
    {
      "id": "01J42GFDYE5Q8QD42ZS3ZEV752"
      // ...
    },
  ],
  "next": "01J42GFDYE5Q8QD42ZS3ZEV753",
}

Next Page

In this example, we request the page that starts at the POI with ULID 01J42GFDYE5Q8QD42ZS3ZEV751. As a result, we get a list of two POIs and can tell by the next attribute that we have more results available.

  • Name
    cursor
    Type
    string
    Description

    The cursor to start the next page from.

  • Name
    limit
    Type
    integer
    Description

    Limit the number of items returned.

Cursor pagination using cURL

curl -G https://api.lanewise.app/v1/pois \
  -H "X-API-KEY: {YOUR_API_KEY}" \
  -d cursor="01J42GFDYE5Q8QD42ZS3ZEV753" \
  -d limit=2

Paginated response

{
  "data": [
    {
      "id": "01J42GFDYE5Q8QD42ZS3ZEV753",
      // ...
    },
    {
      "id": "01J42GFDYE5Q8QD42ZS3ZEV754"
      // ...
    },
  ],
  "next": "01J42GFDYE5Q8QD42ZS3ZEV755",
}

Last Page

In this example, we request the page that starts at the POI with ULID fbwYwpi9C2ybt6Yb. As a result, we get a list of one POI and can tell by the next attribute that we have reached the end of the resultset.

  • Name
    cursor
    Type
    string
    Description

    The cursor to start the next page from.

  • Name
    limit
    Type
    integer
    Description

    Limit the number of items returned.

Cursor pagination using cURL

curl -G https://api.lanewise.app/v1/pois \
  -H "X-API-KEY: {YOUR_API_KEY}" \
  -d cursor="01J42GFDYE5Q8QD42ZS3ZEV755" \
  -d limit=2

Paginated response

{
  "data": [
    {
      "id": "01J42GFDYE5Q8QD42ZS3ZEV755",
      // ...
    },
  ],
  "next": null,
}