Pagination

Navigate large result sets with pagination.

Overview

List endpoints return paginated results. Use query parameters to navigate through large datasets.

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number (1-based)
per_pageinteger25Items per page (max: 100)

Example

curl -X GET "https://api.whatalo.com/v1/products?page=2&per_page=50" \
  -H "X-API-Key: wk_live_your_key_here"

Response Metadata

Every list response includes pagination metadata:

{
  "data": [...],
  "pagination": {
    "page": 2,
    "per_page": 50,
    "total": 142,
    "total_pages": 3
  }
}

Iterating All Pages

async function fetchAllProducts() {
  const allProducts = [];
  let page = 1;
  let hasMore = true;

  while (hasMore) {
    const res = await fetch(
      `https://api.whatalo.com/v1/products?page=${page}&per_page=100`,
      { headers: { 'X-API-Key': API_KEY } }
    );
    const { data, pagination } = await res.json();

    allProducts.push(...data);
    hasMore = page < pagination.total_pages;
    page++;
  }

  return allProducts;
}

Best Practices

  1. Use per_page=100 for bulk operations to minimize requests
  2. Use total_pages to detect when you have reached the last page
  3. Don't fetch all pages at once — implement lazy loading in UIs
  4. Use count endpoints (/products/count) when you only need the total

On this page