Reference
Pagination
Lists of agents, calls, campaigns, phone numbers and entities are paged:
page starts at 1, limit goes from 1 to 100 (50 by default), and the response gives pageCount.async function* allCalls(query = {}) {
for (let page = 1, pageCount = 1; page <= pageCount; page++) {
const params = new URLSearchParams({ ...query, page, limit: 100 });
const res = await fetch(`https://api.callshift.ai/v1/calls?${params}`, {
headers: { Authorization: `Bearer ${process.env.CALLSHIFT_API_KEY}` },
});
const body = await res.json();
pageCount = body.pageCount;
yield* body.data;
}
}
for await (const call of allCalls({ campaignId })) console.log(call.id, call.endedReason);def all_calls(**query):
page, page_count = 1, 1
while page <= page_count:
res = requests.get(
"https://api.callshift.ai/v1/calls",
headers={"Authorization": f"Bearer {os.environ['CALLSHIFT_API_KEY']}"},
params={**query, "page": page, "limit": 100},
).json()
page_count = res["pageCount"]
yield from res["data"]
page += 1
for call in all_calls(campaignId=campaign_id):
print(call["id"], call["endedReason"])Other lists
- Invoices use a cursor: pass the
nextCursorof a response ascursor; it isnullon the last page. - Tools, webhooks and SIP trunks come in a single response.
