Pagination

The NXSYS API implements pagination to help manage large datasets efficiently. This guide explains how to work with paginated responses.

Pagination Parameters

When making requests to endpoints that return lists of items, you can use the following query parameters to control pagination:

  • page: The page number you want to retrieve (default: 1)
  • size: Number of items per page (default: 20, max: 100)

Example Request

GET https://dev-api.nxsys.tech/v1/items?page=2&size=50

Response Format

Paginated responses include the following metadata in the response body:

{
  "data": [...],
  "totalDocs": 150
}

Where:

  • data: Array containing the requested items
  • totalDocs: Total number of items available

Example Usage

Here's an example of how to handle pagination in your code:

async function fetchAllPages() {
  let currentPage = 1;
  let allItems = [];
  
  while (true) {
    const response = await fetch(`https://dev-api.nxsys.tech/v1/items?page=${currentPage}`);
    const data = await response.json();
    
    allItems = [...allItems, ...data.data];
    
    if (allItems.length === data.totalDocs) {
      break;
    }
    
    currentPage++;
  }
  
  return allItems;
}