API Documentation
Pagination
How to work with paginated list responses
All list endpoints return a consistent paginated response shape.
Response format
{
"customers": [...],
"total": 2783,
"hasMore": true,
"nextCursor": "eyJpZCI6IjEyMyJ9"
}| Field | Type | Description |
|---|---|---|
[resource] | array | The list of items (e.g. customers, events, invoices) |
total | number | Total count of items in the collection — unaffected by limit |
hasMore | boolean | true if more results exist beyond this page |
nextCursor | string | Cursor to pass in the next request — absent when hasMore is false |
Request parameters
| Parameter | Default | Max | Description |
|---|---|---|---|
limit | 10 | 1,000 | Number of items to return |
cursor | — | — | Cursor from the previous response to fetch the next page |
Iterating all pages
async function fetchAll<T>(
fetchPage: (cursor?: string) => Promise<{ data: T[]; hasMore: boolean; nextCursor?: string }>
): Promise<T[]> {
const results: T[] = [];
let cursor: string | undefined;
do {
const page = await fetchPage(cursor);
results.push(...page.data);
cursor = page.nextCursor;
} while (page.hasMore);
return results;
}def fetch_all(fetch_page):
results = []
cursor = None
while True:
page = fetch_page(cursor=cursor)
results.extend(page.data)
if not page.has_more:
break
cursor = page.next_cursor
return resultsimport VayuSDK "github.com/weft-finance/vayu-go"
vayu := VayuSDK.NewVayu(os.Getenv("VAYU_API_TOKEN"))
var cursor *string
for {
resp, err := vayu.Customers.ListCustomers(nil, cursor)
if err != nil {
panic(err)
}
for _, c := range resp.Customers {
fmt.Println(c.Id)
}
if !resp.HasMore {
break
}
cursor = &resp.NextCursor
}
