Pagination
Navigate through large result sets with page-based pagination.
Overview
All list endpoints return paginated results. The default page size is 20 items, with a maximum of 100.
Query Parameters
| Parameter | Type | Default | Max | Description |
|---|---|---|---|---|
page | integer | 1 | — | Page number (1-indexed) |
limit | integer | 20 | 100 | Items per page |
Response Metadata
Collection responses include pagination metadata in the meta object:
{
"data": [
{ "id": "...", "type": "lead", "attributes": { ... } },
{ "id": "...", "type": "lead", "attributes": { ... } }
],
"meta": {
"total": 142,
"page": 1,
"limit": 20,
"hasMore": true,
"requestId": "550e8400-e29b-41d4-a716-446655440000"
}
}| Field | Type | Description |
|---|---|---|
total | integer | Total number of matching records |
page | integer | Current page number |
limit | integer | Items per page |
hasMore | boolean | Whether more pages exist |
requestId | string | Request correlation ID |
Examples
Basic Pagination
# First page (default 20 items)
curl -H "Authorization: Bearer lw_live_xxxx" \
https://api.lend.works/v1/leads
# Second page with 50 items per page
curl -H "Authorization: Bearer lw_live_xxxx" \
"https://api.lend.works/v1/leads?page=2&limit=50"Iterating All Pages
import { LendWorksClient } from '@lendworks/sdk-node'
const client = new LendWorksClient({ apiKey: 'lw_live_xxxx' })
let page = 1
let hasMore = true
while (hasMore) {
const result = await client.leads.list({ page, limit: 100 })
for (const lead of result.data) {
console.log(lead.attributes.businessName)
}
hasMore = result.meta.hasMore
page++
}With fetch
async function fetchAllLeads() {
const leads = []
let page = 1
while (true) {
const res = await fetch(
`https://api.lend.works/v1/leads?page=${page}&limit=100`,
{ headers: { Authorization: 'Bearer lw_live_xxxx' } }
)
const { data, meta } = await res.json()
leads.push(...data)
if (!meta.hasMore) break
page++
}
return leads
}Sorting
List endpoints return results sorted by createdAt in descending order (newest first) by default. Endpoints that support search may return results sorted by relevance when a search term is provided.
Best Practices
- Use the smallest
limitthat meets your needs to reduce response time - Check
hasMorerather than comparingpage * limit < totalto handle concurrent changes - For large exports, iterate with
limit=100and process in batches - Cache page results client-side when appropriate to reduce API calls