Get startedPagination & errors

Pagination & errors

List endpoints return results in pages using opaque cursors, and every failure follows one predictable error shape. Handle both once and you're covered across the whole API.

Cursor pagination

List responses wrap rows in a data array alongside a pagination object. To fetch the next page, pass the nextCursor value back as the cursor query parameter. Keep going until nextCursor comes back null — that is the last page.

ParameterTypeDescription
limitintegerRows per page. Default 50, maximum 200.
cursorstringOpaque cursor from a previous response's nextCursor.

The pagination object on every list response:

pagination
"pagination": {
  "nextCursor": "eyJpZCI6MTQ4Mn0",
  "limit": 50
}

Paging through every result

async function listAll(params = {}) {
  const out = [];
  let cursor = null;

  do {
    const qs = new URLSearchParams({ ...params, limit: "200", ...(cursor ? { cursor } : {}) });
    const res = await fetch(`https://api.gpus.io/v1/prices?${qs}`, {
      headers: { Authorization: `Bearer ${process.env.GPUS_API_KEY}` },
    });
    const page = await res.json();
    out.push(...page.data);
    cursor = page.pagination.nextCursor;
  } while (cursor);

  return out;
}

Errors

GPUs.io uses conventional HTTP status codes and returns a single, consistent error envelope. The code is a stable, machine-readable string you can branch on; some errors add an optional details object.

400 Bad Request
{
  "error": {
    "code": "INVALID_PARAMETER",
    "message": "Invalid minVram: must be a non-negative number"
  }
}

Status codes

StatusCodeMeaning
200Success.
400INVALID_PARAMETERA parameter is missing, malformed, or out of range.
401UNAUTHORIZEDMissing, malformed, or unknown API key.
404NOT_FOUNDThe requested resource (e.g. a GPU key) doesn't exist.
429RATE_LIMITEDYou exceeded a rate limit — see Rate limits.
500INTERNALSomething went wrong on our end. Safe to retry.

Handling errors

const res = await fetch(url, { headers });

if (!res.ok) {
  const { error } = await res.json();
  if (res.status === 429) {
    const retry = Number(res.headers.get("Retry-After") || 1);
    await new Promise(r => setTimeout(r, retry * 1000));
    // ...then retry
  }
  throw new Error(`${error.code}: ${error.message}`);
}
© 2026 GPUs.io · API v1