Pagination Basics
List endpoints return paginated results. By default, you get 20 items per page.
Use the page and per_page query parameters to navigate.
Query Parameters
page— 1-indexed page number (default: 1)per_page— items per page (default: 20, max: 100)
Response Format
Paginated responses include metadata alongside the data array:
{
"data": [
{ "id": 1, "name": "Product A", ... },
{ "id": 2, "name": "Product B", ... }
],
"page": 1,
"per_page": 20,
"total": 142,
"total_pages": 8
}
Iterating All Pages
To fetch all items, loop until page > total_pages:
# Fetch page 1, then increment
curl "https://yourshop.zeroshop.io/admin/api/products?page=1&per_page=50" \
-H "Authorization: Bearer zspat_..."
# Check total_pages in response, repeat for page=2, page=3, etc.
import requests
headers = {"Authorization": "Bearer zspat_..."}
base = "https://yourshop.zeroshop.io/admin/api/products"
page = 1
all_products = []
while True:
resp = requests.get(base, headers=headers, params={"page": page, "per_page": 50})
data = resp.json()
all_products.extend(data["data"])
if page >= data["total_pages"]:
break
page += 1
print(f"Fetched {len(all_products)} products")
const headers = { "Authorization": "Bearer zspat_..." };
const base = "https://yourshop.zeroshop.io/admin/api/products";
const allProducts = [];
let page = 1;
while (true) {
const resp = await fetch(`${base}?page=${page}&per_page=50`, { headers });
const data = await resp.json();
allProducts.push(...data.data);
if (page >= data.total_pages) break;
page++;
}
console.log(`Fetched ${allProducts.length} products`);
require "net/http"
require "json"
base = URI("https://yourshop.zeroshop.io/admin/api/products")
headers = { "Authorization" => "Bearer zspat_..." }
page = 1
all_products = []
loop do
uri = URI("#{base}?page=#{page}&per_page=50")
req = Net::HTTP::Get.new(uri)
headers.each { |k, v| req[k] = v }
resp = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(resp.body)
all_products.concat(data["data"])
break if page >= data["total_pages"]
page += 1
end
puts "Fetched #{all_products.length} products"