Pagination
All list endpoints use page-based pagination with zero-based page indexing.
Request parameters
Pass these as query string parameters on any list (GET) endpoint:
| Parameter | Type | Default | Description |
|---|---|---|---|
pageSize |
integer | 10 |
Number of results per page (max 100) |
pageIndex |
integer | 0 |
Zero-based page index (first page = 0) |
Example request
GET /v1/contacts?pageSize=25&pageIndex=0
x-ysuite-access-key: YOUR_ACCESS_KEY
x-ysuite-secret-key: YOUR_SECRET_KEY
Response format
List responses are wrapped in the standard envelope. The data field contains the page metadata and records:
{
"success": true,
"data": {
"data": [ { ... }, { ... } ],
"current_page": 1,
"total_records": 84,
"total_pages": 4
}
}
| Field | Description |
|---|---|
data |
Array of records for this page |
current_page |
The current page number (1-based display) |
total_records |
Total number of matching records |
total_pages |
Total number of pages at the current pageSize |
Fetching all pages
const headers = {
'x-ysuite-access-key': process.env.YSUITE_ACCESS_KEY,
'x-ysuite-secret-key': process.env.YSUITE_SECRET_KEY,
};
let pageIndex = 0;
let allContacts = [];
let totalPages = 1;
do {
const url = `https://api.ysuite.org/v1/contacts?pageSize=100&pageIndex=${pageIndex}`;
const res = await fetch(url, { headers });
const { data } = await res.json();
allContacts.push(...data.data);
totalPages = data.total_pages;
pageIndex++;
} while (pageIndex < totalPages);