Easy Labs
SDKsNode.js

Pagination

List endpoints, cursors, and auto-pagination helpers.

Easy Labs list endpoints use offset/limit pagination. Every method that returns a collection accepts an optional PaginationParams object:

type PaginationParams = {
  limit?: number;
  offset?: number;
  ids?: string[];
};

limit caps the page size, offset skips that many records, and ids is a server-side filter that returns only the resources whose IDs match (useful for batch reads — the SDK joins them with commas and sends them as the ids query parameter).

The API does not return a next cursor. Walk pages by incrementing offset until the response is shorter than limit.

Manual pagination

import { createClient } from "@easylabs/node";

const easy = await createClient({ apiKey: process.env.EASY_API_KEY! });

const pageSize = 100;
let offset = 0;
const all: Awaited<ReturnType<typeof easy.getCustomers>>["data"] = [];

while (true) {
  const page = await easy.getCustomers({ limit: pageSize, offset });
  all.push(...page.data);
  if (page.data.length < pageSize) break;
  offset += pageSize;
}

A few endpoints wrap the rows in a paginated envelope instead of returning a bare array. The shape varies by endpoint — the rows live under a named key, not always data:

MethodEnvelope (under response.data)
getCustomerSubscriptions{ data: SubscriptionData[], total, limit, offset }
listWebhookDeliveries{ deliveries: WebhookDelivery[], limit, offset, total, event_counts?, failed_count?, success_count? }
listEndpointDeliveries{ deliveries: WebhookDelivery[], limit, offset, total }

Use total for an exact stop condition when present, and read the rows from the right key:

// Subscriptions — rows under `data`
const subs = await easy.getCustomerSubscriptions(customerId, { limit: 50, offset });
if (offset + subs.data.data.length >= subs.data.total) break;

// Webhook deliveries — rows under `deliveries`
const page = await easy.listWebhookDeliveries({ limit: 50, offset });
if (offset + page.data.deliveries.length >= page.data.total) break;

Auto-pagination

The 0.1 SDK does not ship an iterator helper. Wrap the manual loop above in an async function* if you want one:

async function* eachCustomer() {
  const limit = 100;
  let offset = 0;
  while (true) {
    const { data } = await easy.getCustomers({ limit, offset });
    if (!data.length) return;
    for (const c of data) yield c;
    if (data.length < limit) return;
    offset += limit;
  }
}

for await (const customer of eachCustomer()) {
  console.log(customer.id);
}

On this page