Pagination
Using Pagination in the API with Query Parameters
When dealing with large responses, the API paginates results to make responses more manageable. To retrieve specific pages of data, you can use query parameters in the request URL.
Key Pagination Fields in the Response
count
: Total number of items available across all pages.next
: URL for the next page of results, if available. This will benull
if you’re on the last page.previous
: URL for the previous page of results, if available. This will benull
if you’re on the first page.results
: List of data items for the current page.
Query Parameters
page
: This parameter allows you to request a specific page of results.page_size
: This parameter defines how many items should be returned per page. If not specified, the API will use a default value.
Example Response
How to Use Pagination with Query Parameters:
Initial Request:
By default, the API returns the first page of results. You can control the number of results per page with the
page_size
parameter.Example request for the first 10 results:
Navigating to the Next Page:
To retrieve the next page of results, use the URL in the
next
field or set thepage
parameter manually.Example:
Going Back to the Previous Page:
Similarly, you can use the
previous
field or specify the page in the request URL to go back.Example:
Customizing Page Size:
If you need more or fewer items per page, use the
page_size
parameter to control how many results are returned on each page.Example for 25 results per page:
Handling Edge Cases:
next
isnull
: You’re on the last page of results.previous
isnull
: You’re on the first page of results.
Last updated