Skip to Content
Won.dev

Pagination

Lists come one page at a time. Pass `next_cursor` back as `cursor` for the next page.

Every list takes limit and cursor, and answers with has_more and next_cursor. Trade data and enrichment lists also say in total how many results match in all.

ParameterWhat it does
limitHow many results to return. Each endpoint states its default and its maximum, at most 100.
cursorThe next_cursor of the previous page, passed back unchanged. Leave it out for the first page.
FieldWhat it says
has_moreWhether another page follows.
next_cursorThe cursor of the next page, or null on the last one.
totalHow many results match in all. Trade data and enrichment lists have it; cold email lists and GET /account/charges do not.

An example

The first page:

curl https://api.won.dev/v1/trade/companies/search \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "role": "importer", "hs_code": "940161", "importer_country": "US", "limit": 25 }'
{
  "data": [{ "id": "co_8f3k2m9x4p1q", "name": "SAMPLE NORTHFIELD HOME FURNISHINGS INC" }],
  "total": 4087,
  "has_more": true,
  "next_cursor": "cur_Zx81kQp4b2JtMW0uMXJ6ZzQ"
}

The next page is the same request with cursor:

curl https://api.won.dev/v1/trade/companies/search \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "role": "importer", "hs_code": "940161", "importer_country": "US", "limit": 25, "cursor": "cur_Zx81kQp4b2JtMW0uMXJ6ZzQ" }'

Every page until next_cursor is null:

const query = { role: "importer", hs_code: "940161", importer_country: "US", limit: 100 };
const companies = [];
let cursor = null;
do {
  const response = await fetch("https://api.won.dev/v1/trade/companies/search", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.WON_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(cursor ? { ...query, cursor } : query),
  });
  const page = await response.json();
  companies.push(...page.data);
  cursor = page.next_cursor;
} while (cursor);

Each page of a paid list is charged for the results it returns. Set max_cost to cap each call, and ask for the whole list only when you need it.

Rules

  • A cursor only works with the parameters that produced it. limit may change from page to page; any other change means starting again without cursor.
  • A cursor expires 24 hours after it was issued. A cursor that has expired, or that belongs to another query, fails with invalid_input on cursor.
  • A trade data list or a search of companies can be paged through its first 10,000 results. To get past them, narrow it: a shorter date range, a country or a longer hs_code.
  • When a list changes while you page through it, a result can show up twice or be missed. Tell results apart by id, and use GET /events to keep up with what is new.
  • Some lists are a single page: they take limit and no cursor, and have no has_more. GET /trade/hs-codes returns the best matches this way, and GET /webhooks/{id}/deliveries the latest deliveries.

Events

GET /events is a feed you keep reading, so its cursor works differently:

  • next_cursor is the ID of the last event you got, such as evt_5r4k2m9x7p1q8w3e.
  • It is set on the last page too, and when there is nothing new it is the cursor you sent. Store it and pass it next time to get exactly what is new, each event once.
  • It does not expire while its event is kept, which is 30 days.

MCP

The MCP tools page the same way, with limit and cursor, and return at most 50 results per call.

On this page