Pagination
How hoshime list endpoints page through results with an opaque cursor and a limit, and how to read every page until hasMore is false.
View as MarkdownA list endpoint returns the page’s items as data and says where the list goes on in meta.pagination:
{
"data": [{ "id": "…" }, { "id": "…" }],
"meta": {
"requestId": "req_…",
"platform": "youtube",
"endpoint": "search",
"cached": false,
"fetchedAt": "2026-11-06T15:41:53Z",
"units": 1,
"pagination": { "nextCursor": "EpcDEgV…", "hasMore": true, "total": null }
}
}
- Pass
meta.pagination.nextCursoras thecursorparameter to get the next page. - On the last page,
hasMoreis false andnextCursoris empty. - Cursors are opaque. Never build or parse one: pass back what you were given.
limitsets the page size where the source allows it, from 1 to the endpoint’s maximum, with a default. An endpoint whose source has a fixed page size takes nolimit.totalcounts the items of every page when the source says, else it is null.- Only list endpoints take
cursorandlimit. No endpoint pages withpage,offsetorperPage.
Read every page
async function* all(path, params = {}) {
let cursor = "";
do {
const q = new URLSearchParams({ ...params, ...(cursor && { cursor }) });
const res = await fetch(`https://api.hoshime.com${path}?${q}`, {
headers: { Authorization: `Bearer ${process.env.HOSHIME_TOKEN}` },
});
const { data, meta } = await res.json();
yield* data;
cursor = meta.pagination.nextCursor;
} while (cursor);
}
for await (const comment of all("/v1/youtube/comments", { id: "dQw4w9WgXcQ" })) {
console.log(comment.text);
}
Each page is one call and bills its own units.
Export every page
To collect a whole list, such as every comment of a post, let hoshime read the pages for you. Name the endpoint and its parameters, without cursor or limit:
curl -X POST https://api.hoshime.com/v1/exports \
-H "Authorization: Bearer $HOSHIME_TOKEN" \
-d '{"export": {"platform": "tiktok", "endpoint": "comments", "params": {"id": "7300000000000000000"}, "maxItems": 5000}}'
The export runs in the background. GET /v1/exports/:jobId shows its status and exportResult (items and pages read, whether the list was read to its end, units billed). When it has succeeded, download the items once each, in order:
curl -o comments.csv "https://api.hoshime.com/v1/exports/$JOB_ID/download?format=csv" \
-H "Authorization: Bearer $HOSHIME_TOKEN"
format=json (the default) gives one JSON array. CSV has a column per field, nested fields as author.username, and lists as JSON. Each page bills what calling the endpoint bills, a cached page nothing; the download is free. A failed export keeps the items it read, and they stay billed and downloadable.