Pagination

Many Treatar endpoints return paginated results to improve performance and reduce response size.

Use pagination to retrieve large datasets in manageable chunks.


Query Parameters

Parameter
Type
Required
Description

limit

integer

No

Number of records per page (default system value applies if not provided)

page

integer

No

Page number to retrieve


Example Request

GET https://api.treatar.com/v1/products?limit=25&page=1

Response Structure

Paginated responses include a pagination object alongside the main data.

{
  "status": true,
  "message": "Records fetched successfully",
  "data": [],
  "pagination": {
    "total": 7,
    "current_page": 1,
    "per_page": 25,
    "last_page": 1,
    "next_page": null,
    "previous_page": null,
    "total_pages": 1,
    "has_previous_page": false,
    "has_next_page": false
  }
}

Pagination Fields

Field
Description

total

Total number of records available

current_page

Current page returned

per_page

Number of records per page

last_page

Last available page

next_page

Next page number (null if none)

previous_page

Previous page number (null if none)

total_pages

Total number of pages

has_next_page

Indicates if another page exists

has_previous_page

Indicates if a previous page exists

  • Start with page=1

  • Use has_next_page to determine if more data should be requested

  • Avoid requesting very large limit values

  • For dashboards or reports, store the current page to maintain user position

Last updated