REST API

Jobs

Poll background work and collect every page of results.

GET https://www.ninjabuy.com/api/v1/jobs/{id} requires the same account's bearer token. Missing, unknown and other accounts' jobs return 404.

Lifecycle

job.statusMeaning
queuedWaiting to start.
runningWork is in progress; more results may arrive.
doneProcessing finished. Check each result's status.
failedThe job failed. Read job.error when present.

job includes id, kind, status and startedAt, plus optional progress (done, total), finishedAt, result and error. Timestamps are milliseconds since the Unix epoch. While queued or running, poll_after_seconds and the Retry-After header tell you how long to wait; the initial suggestion is 5 seconds.

Link batches have kind: "link_mints". Their final result reports total, converted, failed and optional campaign and label. Here failed counts inputs answered without conversion; it does not mean the whole job's status is failed. Sheet conversions have kind: "sheet_conversion"; their final job.result contains counts and a signed XLSX download URL. The job schema also covers sheet_read, picture_copy and resolution_run.

Cursor paging

The response contains job, results, cursor, has_more and request_id. Each page contains up to 50 results in input order.

  1. Omit cursor for the first page (offset 0).
  2. Consume results and retain any non-null returned cursor.
  3. When has_more is true, request the next page with ?cursor=RETURNED_CURSOR.
  4. If has_more is false while queued or running, wait poll_after_seconds, then poll with the retained cursor. More results can arrive later.
  5. Finish only when the job is done or failed and all result pages have been read (cursor is null).

A cursor must be a single query parameter of 1 to 6 digits (0 to 999999). Invalid or repeated cursor parameters return 400. Do not treat has_more: false alone as completion. See the curl examples.