Pagination
List endpoints return paginated results to keep response sizes manageable. The Sellvy API uses two pagination styles depending on the resource. All list responses include a pagination object with metadata you can use to navigate through results.
Page-based pagination
Used by Products, Orders, and Customers. Pass a page number and limit to control which slice of results you receive.
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| page | integer | 1 | The page number to retrieve (1-indexed). |
| limit | integer | 20 | Number of items per page. Maximum: 100. |
The response includes a pagination object with the current page, limit, total item count, and total number of pages:
curl "https://sellvy.io/api/v1/products?page=2&limit=10" \
-H "X-API-Key: sk_live_..."Response
{
"data": [
{
"id": "prod_k8m2x9",
"title": "Premium Icon Pack",
"slug": "premium-icon-pack",
"price": 14.99,
"type": "download",
"visibility": "public",
"created_at": "2025-03-10T14:22:00Z"
},
{
"id": "prod_r4n7p1",
"title": "Discord Bot License",
"slug": "discord-bot-license",
"price": 9.99,
"type": "serial",
"visibility": "public",
"created_at": "2025-03-08T09:15:00Z"
}
],
"pagination": {
"page": 2,
"limit": 10,
"total": 47,
"pages": 5
}
}Offset-based pagination
Used by Coupons and Categories. Instead of page numbers, pass an offset (number of items to skip) and limit to control the result window.
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| offset | integer | 0 | Number of items to skip before starting to return results. |
| limit | integer | 20 / 50 | Number of items to return. Default varies by resource (20 for coupons, 50 for categories). See the limits table below. |
The response includes a pagination object with the limit, offset, and total count:
curl "https://sellvy.io/api/v1/categories?offset=50&limit=25" \
-H "X-API-Key: sk_live_..."Response
{
"data": [
{
"id": "cat_v3x8n2",
"name": "Templates",
"slug": "templates",
"sort_order": 3,
"product_count": 12,
"created_at": "2025-02-20T11:00:00Z"
}
],
"pagination": {
"limit": 25,
"offset": 50,
"total": 128
}
}Default and maximum limits
Each resource has its own default and maximum limit value. Requesting a limit above the maximum will silently clamp to the allowed maximum.
| Resource | Pagination style | Default limit | Max limit |
|---|---|---|---|
| Products | Page-based | 20 | 100 |
| Orders | Page-based | 20 | 100 |
| Customers | Page-based | 20 | 100 |
| Coupons | Offset-based | 20 | 100 |
| Categories | Offset-based | 50 | 200 |
Iterating through all pages
To fetch every item in a collection, loop through pages until you have retrieved all results. Here is a complete example using page-based pagination:
async function fetchAllProducts(apiKey) {
const baseUrl = "https://sellvy.io/api/v1/products";
const limit = 100;
let page = 1;
let allProducts = [];
while (true) {
const res = await fetch(`${baseUrl}?page=${page}&limit=${limit}`, {
headers: { "X-API-Key": apiKey }
});
const { data, pagination } = await res.json();
allProducts = allProducts.concat(data);
// Stop when we've reached the last page
if (page >= pagination.pages) break;
page++;
}
return allProducts;
}
const products = await fetchAllProducts("sk_live_...");
console.log(`Fetched ${products.length} products`);