Pagination
Working with paginated responses in the Ping Proxies API
The Ping Proxies API uses pagination to manage large result sets efficiently. Without pagination, endpoints that return many items could slow down your application and consume unnecessary bandwidth.
How Pagination Works
When you make a request to an endpoint that returns multiple items (like search endpoints), the API divides the results into pages and returns one page at a time. This approach:
- Improves performance for large datasets
- Reduces bandwidth consumption
- Provides more predictable response times
- Makes responses easier to process
Pagination Parameters
Ping Proxies API uses the following query parameters to control pagination:
Parameter | Type | Description | Default |
---|---|---|---|
page | integer | The page number to retrieve | 1 |
per_page | integer | Number of items to return per page | 100 |
Example Request
This request would retrieve the second page of proxies, with 25 proxies per page.
Pagination Response
Paginated responses include metadata to help you navigate through all available results. Here’s what you’ll find in a typical paginated response:
Pagination Response Fields
Field | Description |
---|---|
data | Array containing the items for the current page |
item_count | Number of items returned in the current page |
page | Current page number |
per_page | Number of items requested per page |
total_count | Total number of items that match your search criteria across all pages |
Calculating Total Pages
To calculate the total number of pages, use:
Pagination Limits
- Minimum
per_page
: 1 - Maximum
per_page
: 100 - Default
per_page
: 100 - Minimum
page
: 1
If you request a page beyond the available data, you’ll receive an empty data array
Code Examples
Efficient Pagination Strategies
Sequential Paging
The simplest approach is to request page 1, then page 2, and so on. This is demonstrated in the code examples above for each language.
Parallel Paging
For faster data collection, you can calculate the total pages and make multiple concurrent requests. This approach is particularly useful when you need to retrieve a large dataset quickly.
The parallel examples above show how to implement this pattern in different languages.
Use parallel paging cautiously to avoid rate limiting. Consider how many concurrent requests you’re making to the API.