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:

ParameterTypeDescriptionDefault
pageintegerThe page number to retrieve1
per_pageintegerNumber of items to return per page100

Example Request

GET https://api.pingproxies.com/1.0/public/user/proxy/search?page=2&per_page=25

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:

{
  "data": [
    // Array of items for the current page
  ],
  "item_count": 25,     // Number of items in the current page
  "message": "Search successful",
  "page": 2,            // Current page number
  "per_page": 25,       // Items per page
  "total_count": 134    // Total items across all pages
}

Pagination Response Fields

FieldDescription
dataArray containing the items for the current page
item_countNumber of items returned in the current page
pageCurrent page number
per_pageNumber of items requested per page
total_countTotal number of items that match your search criteria across all pages

Calculating Total Pages

To calculate the total number of pages, use:

total_pages = Math.ceil(total_count / per_page)

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

# Basic pagination example with cURL
curl --request GET \
  --url 'https://api.pingproxies.com/1.0/public/user/proxy/search?page=2&per_page=25' \
  --header 'X-API-Public-Key: your_public_key' \
  --header 'X-API-Private-Key: your_private_key'

# Fetch all pages sequentially with bash
#!/bin/bash
page=1
per_page=100
total_items=0
total_pages=0

# First request to get total count
response=$(curl -s \
  --url "https://api.pingproxies.com/1.0/public/user/proxy/search?page=${page}&per_page=${per_page}" \
  --header 'X-API-Public-Key: your_public_key' \
  --header 'X-API-Private-Key: your_private_key')

total_items=$(echo $response | jq -r '.total_count')
total_pages=$(( (total_items + per_page - 1) / per_page ))

echo "Total items: $total_items, Total pages: $total_pages"

# Fetch each page
for ((page=1; page<=total_pages; page++)); do
  echo "Fetching page $page of $total_pages"
  curl -s \
    --url "https://api.pingproxies.com/1.0/public/user/proxy/search?page=${page}&per_page=${per_page}" \
    --header 'X-API-Public-Key: your_public_key' \
    --header 'X-API-Private-Key: your_private_key' \
    > "page_${page}.json"
done

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.