Pagination

In this guide, we will look at how to work with paginated responses when querying the TripEdge API. Paginated endpoints return results with a default limit, which you can adjust using the limit parameter.

Pagination parameters

The bookings endpoint supports pagination with the following parameters:

  • Name
    page
    Type
    integer
    Description

    The page number to retrieve (1-indexed). Defaults to 1.

  • Name
    limit
    Type
    integer
    Description

    The number of items per page. Defaults to 50.

Example

In this example, we request the second page of bookings with 25 items per page.

Paginated request

curl -G https://api.tripedge.com/v1/book \
  -H "Authorization: Bearer {your_api_key}" \
  -d page=2 \
  -d limit=25

Paginated response

{
  "success": true,
  "data": [
    {
      "id": 98765,
      "status": "confirmed",
      "hotel_id": 12345
      // ...
    },
    {
      "id": 98766,
      "status": "confirmed",
      "hotel_id": 12346
      // ...
    }
  ],
  "total": 150,
  "message": null
}

Response format

Paginated responses include a total field indicating the total number of items across all pages. Use this to calculate the total number of pages:

const totalPages = Math.ceil(response.total / limit)

Was this page helpful?