Pagination, errors & retries
A useful client handles more than the happy path. Treat authorization failures, rate limits, and empty pages as explicit states.
Paginate pinned introductions
GET /introductions uses zero-based page and pageSize (maximum 100). Responses include page, pageSize, and totalCount. Fetch the next page while (page + 1) * pageSize < totalCount.
- JavaScript
- Python
const base = 'https://api.vieu.com/api/v2';
let page = 0;
while (true) {
const url = new URL(`${base}/introductions`);
url.searchParams.set('page', String(page));
url.searchParams.set('pageSize', '100');
const response = await fetch(url, {
headers: { 'x-api-key': process.env.VIEU_API_KEY },
});
const body = await response.json();
if (!response.ok) throw new Error(JSON.stringify(body));
console.log(body); // Process this page in your integration.
if ((body.page + 1) * body.pageSize >= body.totalCount) break;
page += 1;
}
import os
import requests
base = "https://api.vieu.com/api/v2"
page = 0
while True:
response = requests.get(
f"{base}/introductions",
params={"page": page, "pageSize": 100},
headers={"x-api-key": os.environ["VIEU_API_KEY"]},
timeout=15,
)
response.raise_for_status()
body = response.json()
print(body) # Process this page in your integration.
if (body["page"] + 1) * body["pageSize"] >= body["totalCount"]:
break
page += 1
Search endpoints and saved-list endpoints have different response shapes. Do not apply this pagination loop to every route.
Choose your response to each error
| Status | What to do |
|---|---|
| 400 | Fix the parameters; resending the same request will not help. |
| 401 | Check or rotate the key. |
| 403 | Request the missing scope. |
| 404 | Verify the ID and tenant; the resource may be unavailable. |
| 429 | Honor Retry-After when present, then retry with bounded backoff. |
| 500 | Retry eligible reads with bounded exponential backoff and jitter. |
Limits apply per tenant. Read the RateLimit response header rather than hardcoding a request rate. See rate limits.
Put bounds on retries
Use a timeout for each request and a maximum number of attempts. Do not automatically retry writes unless the operation’s duplicate behavior is understood. A network timeout does not prove a write failed.
For person contact details, a successful response can include tryLater: true while email resolution is in progress. Retry no more often than every 15 seconds; see the contact reference.
Practice failure states
Choose 401 or 429 in the inline example’s demo response scenarios. These are labeled simulations backed by local JSON fixtures, so no live key or rate-limit exhaustion is needed.