Pagination
Navigate paginated results from Salesly API list endpoints.
All list endpoints return paginated results. Use query parameters to navigate through pages.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
per_page | integer | 15 | Number of items per page (max 100) |
page | integer | 1 | Page number to retrieve |
Response Format
Paginated responses include a pagination object alongside the data array:
{
"data": [
{
"id": 1,
"name": "ACME Corp",
"email": "[email protected]",
"created_at": "2026-03-01T10:00:00+00:00"
},
{
"id": 2,
"name": "Globex Inc",
"email": "[email protected]",
"created_at": "2026-03-02T14:30:00+00:00"
}
],
"pagination": {
"total": 42,
"per_page": 2,
"current_page": 1,
"last_page": 21,
"has_more": true
}
}Pagination Fields
| Field | Type | Description |
|---|---|---|
total | integer | Total number of items across all pages |
per_page | integer | Items per page (matches your request) |
current_page | integer | Current page number |
last_page | integer | Last available page number |
has_more | boolean | true if there are more pages after the current one |
Iterating Through Pages
async function fetchAllContacts(apiKey) {
const contacts = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const response = await fetch(
`https://rest.salesly.app/api/v1/developers/contacts?per_page=100&page=${page}`,
{ headers: { "x-api-key": apiKey, "Accept": "application/json" } }
);
const json = await response.json();
contacts.push(...json.data);
hasMore = json.pagination.has_more;
page++;
}
return contacts;
}Best Practices
- Use the smallest
per_pageyou need to reduce response size and latency - Check
has_moreto know when to stop paginating - Do not assume
totalis static — items may be added or removed between pages - For large exports, consider using batch endpoints or pagination with a reasonable
per_page(50–100)