Skip to main content

Pagination

Endpoints that return lists (such as GET /v1/funnels/{funnelId}/contacts) are paginated. You control which page of results you want using query parameters, and the response tells you how many items exist in total and whether more pages follow.

Query parameters

ParameterTypeDefaultConstraintsDescription
pageinteger0min: 0Page number, 0-based
limitinteger501–100Number of items per page
sortFieldstringps_converted_atenum (see below)Field to sort by
sortOrderinteger-1-1 or 1Sort direction: -1 descending, 1 ascending

Allowed values for sortField: ps_converted_at, email, firstName, lastName.

Note: sortField and sortOrder are currently available on the contacts endpoint. Check the individual endpoint reference for which sort options apply.

The meta object

Every paginated response includes a top-level meta object alongside the data array:

{
"data": [ /* array of items */ ],
"meta": {
"total": 342,
"page": 0,
"limit": 50,
"hasNext": true
}
}
FieldTypeDescription
totalnumberTotal number of items across all pages
pagenumberCurrent page number (0-based)
limitnumberItems per page as used for this response
hasNextbooleantrue if there are more pages; false on last page

Fetching a specific page

# Page 0 (first page), 20 contacts per page
curl "https://api.perspective.co/v1/funnels/fnl_xyz789/contacts?page=0&limit=20" \
-H "x-perspective-api-key: $PERSPECTIVE_API_KEY"

# Page 1 (second page)
curl "https://api.perspective.co/v1/funnels/fnl_xyz789/contacts?page=1&limit=20" \
-H "x-perspective-api-key: $PERSPECTIVE_API_KEY"

Iterating through all pages

Use meta.hasNext to drive a loop. Increment page after each successful response and stop when hasNext is false.

# Shell loop — fetch all pages and append to allContacts.json
page=0
limit=100
has_next=true

while [ "$has_next" = "true" ]; do
response=$(curl -s \
"https://api.perspective.co/v1/funnels/fnl_xyz789/contacts?page=$page&limit=$limit" \
-H "x-perspective-api-key: $PERSPECTIVE_API_KEY")

echo "$response" >> allContacts.json

has_next=$(echo "$response" | jq -r '.meta.hasNext')
page=$((page + 1))
done

Tips

  • Start at page 0. The API uses 0-based page numbers; page 1 is the second page, not the first.
  • Respect rate limits. If you are looping through many pages, add a small delay between requests to stay within the 100-requests-per-minute limit. See Errors for rate limit details.
  • Use total for progress. Divide the number of items fetched so far by meta.total to show progress in a data-export flow.
  • Quickstart — end-to-end first call using paginated contacts
  • Errors — 429 Too Many Requests and how to handle rate limiting
  • Contacts API Reference — full query-parameter reference for the contacts endpoint