Quickstart
Create links inline, then collect a batch with curl.
1. Get credentials
Create a personal API key under Account → Referrals → API keys. Copy it when shown and supply it to your script as NINJABUY_API_KEY; keep it private.
For an application acting for other NinjaBuy customers, use OAuth.
2. Create links inline
curl -sS https://www.ninjabuy.com/api/v1/links \
-H "Authorization: Bearer $NINJABUY_API_KEY" \
-H "Content-Type: application/json" \
--data '{"links":["https://weidian.com/item.html?itemID=7581746714"],"campaign":"spring-haul","label":"video 3"}'Up to 100 inputs return 200 with results, warnings and request_id. Each result has an input and status; an ok result includes the credited url and code. Check every row: HTTP success does not mean every input converted. See Links.
3. Start a batch
More than 100 inputs automatically run in the background, up to 2,000 per request. To try a job with one link, set async to true:
curl -sS -D batch-headers.txt https://www.ninjabuy.com/api/v1/links \
-H "Authorization: Bearer $NINJABUY_API_KEY" \
-H "Content-Type: application/json" \
--data '{"links":["https://www.ninjabuy.com/search?q=hoodie"],"async":true}'The response is 202. Location gives a relative path such as /api/v1/jobs/JOB_ID; Retry-After: 5 says when to poll. The body contains job.id, job.status, job.total and job.poll_after_seconds.
4. Read results by cursor
Use the job id from that response. Omit cursor on the first request:
curl -sS "https://www.ninjabuy.com/api/v1/jobs/JOB_ID" \
-H "Authorization: Bearer $NINJABUY_API_KEY"For each later request, pass the returned non-null cursor unchanged:
curl -sS "https://www.ninjabuy.com/api/v1/jobs/JOB_ID?cursor=RETURNED_CURSOR" \
-H "Authorization: Bearer $NINJABUY_API_KEY"Read each page's results. When has_more is true, fetch the next page. When it is false but the job is queued or running, wait poll_after_seconds and poll with the retained cursor. Stop after the job is done or failed and all pages are drained. See Jobs and Errors.
Next steps
Convert a Google Sheet or uploaded XLSX/CSV with Sheets, or find products with Search.