Pagination in GET APIs

Last updated on
27 February 2026

Overview

Pagination allows you to retrieve API results in smaller chunks instead of fetching all records at once. This improves performance, reduces server load, and makes large datasets easier to manage.

Pagination can be applied to any GET API by passing pagination parameters in the request URL.

If pagination parameters are not provided, the API returns the first 100 records.

Click this link to download and get started.

How to Implement Pagination

After creating a GET API, you can enable pagination by adding one of the following query parameter combinations to the request URL:

  • Page-based Pagination ?page=<page_number>&size=<number_of_records>
  • Offset-based Pagination ?offset=<starting_position>&size=<number_of_records>

Pagination Parameters

  • page:
    • Specifies the page number to retrieve.
    • Page numbering is 1-based (starts from 1).
    • Must be used together with the size parameter.
    • Applicable only to GET APIs.
    • Example: https://your-base-url/custom-api/order?page=2&size=25
  • size:
    • Specifies the number of records to return per request.
    • Must be used with either page or offset.
    • If not provided, the API returns all records.
    • Example: size=25 
  • offset:
    • Specifies the starting position of records to return.
    • Offset is 1-based (the first record starts at offset = 1).
    • Must be used together with the size parameter.
    • If both offset and page are provided, offset takes priority and page is ignored.
    • Example: https://your-base-url/custom-api/order?offset=11&size=10

Examples 

  • Example 1: Page-based Pagination:
    • a. Request: GET https://your-base-url/custom-api/order?page=1&size=10
    • Result: Returns the first 10 records.
    • b. Request: GET https://your-base-url/custom-api/order?page=2&size=10
    • Result: Returns the next 10 records.
  • Example 2: Offset-based Pagination:
    • a. Request: GET https://your-base-url/custom-api/order?offset=1&size=10
    • Result: Returns the first 10 records.
    • b. Request: GET https://your-base-url/custom-api/order?offset=11&size=10
    •  Result: Returns records from position 11 to 20.

Contact our 24*7 support team

Feel free to reach out to our Drupal experts if you need any assistance with setting up or configuring Custom APIs on your Drupal site.  

 Get In Touch With Us Join Our Slack Channel

back to top Back to top

Help improve this page

Page status: No known problems

You can: