VayuDocumentationIntegrationsAPI ReferenceChange Log
SupportGet started now
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"
}
FieldTypeDescription
[resource]arrayThe list of items (e.g. customers, events, invoices)
totalnumberTotal count of items in the collection — unaffected by limit
hasMorebooleantrue if more results exist beyond this page
nextCursorstringCursor to pass in the next request — absent when hasMore is false

Request parameters

ParameterDefaultMaxDescription
limit101,000Number of items to return
cursorCursor 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 results
import 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
}

On this page