The page window is cut first, and rows whose stored price can’t be
interpreted are dropped afterwards. So data.length can be less than
limit — even zero — while hasMore is true.Page on hasMore and nextCursor. Never stop because a page came back empty.
async function allSales(collectionId, pages = 20) { const out = []; let cursor = null; let i = 0; do { const qs = new URLSearchParams({ limit: '50', ...(cursor ? { cursor } : {}) }); const { data, pagination } = await fetch( `https://exclusivo.one/v1/collections/${collectionId}/sales?${qs}` ).then(r => r.json()); out.push(...data); // may be empty — keep going cursor = pagination.hasMore ? pagination.nextCursor : null; } while (cursor && ++i < pages); return out;}
Either the id doesn’t resolve, or it resolves to a collection with no stored
contract address — sales are keyed by that address.So a 404 here doesn’t prove the collection doesn’t exist. Check
/v1/collections/{id} to tell the two apart.Errors: 400, 404, 429, 502. Unlike most of this API, sales can 502.
Sum price.raw and do the arithmetic in integer base units. decimal loses
precision on large wei values, and usd can be null on any row.Also worth knowing: rows with prices we couldn’t interpret are dropped before
you see them, so a total from this endpoint is a total of interpretable sales.