Skip to main content
Every list() method in the SW Combine SDK returns a Page<T> object rather than a plain array. This gives you both the items for the current page and the metadata you need to fetch subsequent pages — either manually, one page at a time, or automatically by iterating with for await...of.

The Page<T> object

When you call any list() method, you receive a Page<T> with the following shape:
data
T[]
required
The array of items on the current page.
total
number
required
The total number of items across all pages.
start
number
required
The index of the first item on this page.
count
number
required
The number of items on this page.
hasMore
boolean
required
true when there are additional pages after this one.

Fetching a single page

By default, list() returns the first page of up to 50 items. You can check hasMore to decide whether to fetch more, and call getNextPage() to advance one page at a time.
const page = await client.galaxy.sectors.list();

console.log(page.total);       // e.g. 248 — total sectors in the galaxy
console.log(page.data.length); // up to 50 — items on this page
console.log(page.hasMore);     // true if more pages exist

if (page.hasMore) {
  const nextPage = await page.getNextPage();
  console.log(nextPage.data);
}

Auto-paginating with for await…of

Use for await...of to iterate over every item across all pages without managing page offsets yourself. The SDK fetches subsequent pages as needed until all items are returned.
for await (const sector of await client.galaxy.sectors.list()) {
  console.log(sector.name);
}
Auto-pagination makes one API request per page. For large datasets this can consume a significant portion of your 600 requests/hour quota. Use pageDelay to slow down fetches if needed.

Controlling page size and starting offset

Every list() method accepts start_index and item_count parameters. Pass them to control which slice of results you receive.
start_index
number
default:"1"
The 1-based index of the first item to return. Most endpoints default to 1; the Events endpoint uses 0 as its default.
item_count
number
default:"50"
The number of items to return per page. Controls the page size for both single-page fetches and auto-pagination.
pageDelay
number
default:"0"
Milliseconds to wait between automatic page fetches during for await...of iteration. Use this to stay within rate limits when paginating large datasets.
// Fetch 25 items starting from the 51st
const page = await client.galaxy.sectors.list({
  start_index: 51,
  item_count: 25,
});

// Auto-paginate with a 500 ms delay between each page fetch
for await (const ship of await client.inventory.entities.list({
  item_count: 100,
  pageDelay: 500,
})) {
  console.log(ship.name);
}
Increasing item_count reduces the number of requests needed to page through large datasets. The maximum accepted value depends on the endpoint — check the API reference for per-endpoint limits.

Manual pagination with getNextPage()

If you want explicit control over when the next page is fetched, use getNextPage() in a loop instead of for await...of.
let page = await client.inventory.entities.list({ item_count: 100 });

while (true) {
  for (const entity of page.data) {
    process(entity);
  }

  if (!page.hasMore) break;
  page = await page.getNextPage();
}

Events endpoint

The Events endpoint is the only one that uses a 0-based start_index by default rather than 1-based. This matches the underlying API behavior for that resource — all other endpoints start at 1.
// Events uses 0-based indexing
const events = await client.events.list({ start_index: 0 });

Next steps

Rate limits

Understand the 600 requests/hour quota and how to monitor it.

Error handling

Handle failures gracefully and understand automatic retry behavior.

Quickstart

See pagination in action with a working end-to-end example.

Client modes

Choose the right client mode for your use case.