Pagination

The Jedlix API uses a simple and efficient pagination system to enable developers to navigate through large datasets easily. In this section, we will explain the pagination system used by the Jedlix API and provide examples to help you integrate this feature into your applications.

Pagination Format

The Jedlix API uses page-based pagination and a custom pagination object to organize and present data in the API responses. The object has the following structure:

{
  "pageIndex": 1,
  "pageSize": 20,
  "totalPages": 0,
  "totalCount": 0,
  "items": []
}

Pagination Object Properties

  • pageIndex: The current page index, starting from 1.
  • pageSize: The number of items displayed per page. This value can be adjusted as per your requirements.
  • totalPages: The total number of pages available based on the pageSize and the total number of items in the dataset.
  • totalCount: The total number of items available in the dataset.
  • items: An array containing the data items for the current page.

Implementing Pagination in Your Application

To use pagination in your application, you need to provide the pageIndex and pageSize as query parameters in your API request. Here's an example API request with pagination:

GET https://api.jedlix.com/v1/resources?pageIndex=1&pageSize=20

In this example, we request the first page of resources with a page size of 20 items. The API will return a paginated response containing the requested data.

The maximum value is 100. If this limit is increased, pageSize will be set to 100 on v1 endpoints and will trigger a BadRequest on v2 and later versions.

Handling Paginated Responses

When you receive a paginated response from the JEdlix API, you can use the pagination object properties to navigate through the dataset and display the data as needed. Here's an example of how to handle paginated responses in your application:

  1. Access the items property to retrieve and display the data for the current page.
const response = await fetch('https://api.jedlix.com/v1/resources?pageIndex=1&pageSize=20');
const paginatedResult = await response.json();
const items = paginatedResult.items;

  1. Use the pageIndex, pageSize, totalPages, and totalCount properties to display pagination information and create navigation controls (e.g., previous, next, first, and last page buttons).
const pageIndex = paginatedResult.pageIndex;
const pageSize = paginatedResult.pageSize;
const totalPages = paginatedResult.totalPages;
const totalCount = paginatedResult.totalCount;

With this information, you can create a user interface that allows users to navigate through the dataset using the provided navigation controls.