Salesly API

Pagination

Navigate paginated results from Salesly API list endpoints.

All list endpoints return paginated results. Use query parameters to navigate through pages.

Query Parameters

ParameterTypeDefaultDescription
per_pageinteger15Number of items per page (max 100)
pageinteger1Page number to retrieve

Response Format

Paginated responses include a pagination object alongside the data array:

GET /contacts?per_page=2&page=1
{
  "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

FieldTypeDescription
totalintegerTotal number of items across all pages
per_pageintegerItems per page (matches your request)
current_pageintegerCurrent page number
last_pageintegerLast available page number
has_morebooleantrue 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_page you need to reduce response size and latency
  • Check has_more to know when to stop paginating
  • Do not assume total is 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)