Skip to content

Pagination

List projects is paginated with a cursor. Every other list returns everything at once.

Cursors

Ask for a page with limit (20 by default, 50 at most). The response carries the page's items and a nextCursor:

Terminal
curl "https://api.hiraiship.com/api/v1/projects?limit=50" \
  -H "Authorization: Bearer $HIRAISHIP_TOKEN"
200
{ "items": [ … ], "nextCursor": "eyJjcmVhdGVkQXQiOiIyMDI2LTEw…" }

Pass nextCursor back as cursor for the next page, with the same search if you used one. The last page has nextCursor: null.

A cursor is opaque: don't build or change one. A cursor this route didn't return gets a 400.

All pages, in a script

list-projects.mjs
const headers = { Authorization: `Bearer ${process.env.HIRAISHIP_TOKEN}` };
const projects = [];
let cursor = null;
 
do {
  const url = new URL('https://api.hiraiship.com/api/v1/projects');
  url.searchParams.set('limit', '50');
  if (cursor) url.searchParams.set('cursor', cursor);
 
  const page = await fetch(url, { headers }).then((response) => response.json());
  projects.push(...page.items);
  cursor = page.nextCursor;
} while (cursor);
 
console.log(projects.map((project) => project.slug));

Pages are ordered newest first and the cursor points past the last item, so a project created while you page doesn't shift the next pages.