> ## Documentation Index
> Fetch the complete documentation index at: https://pricepirate.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Jobs

> Create and poll lookup jobs, export results as CSV, and list your job history.

Every lookup is an asynchronous job. You create it, poll it until it finishes, and read the results.

## Create a job

Send `source`, `operation`, `country`, and `queries` to `POST /api/v2/jobs`:

```bash theme={null}
curl --request POST \
  --url https://api-v2.pricepirate.com/api/v2/jobs \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{"source":"idealo","operation":"search-by-gtin","country":"de","queries":["4013474101469","4006381333931"]}'
```

```text theme={null}
HTTP/1.1 202 Accepted
Location: /api/v2/jobs/3f6c0a7e-5d1b-4c39-9a51-2f1f0f8f6b2e
Retry-After: 5
```

```json theme={null}
{ "error": false, "job_id": "3f6c0a7e-5d1b-4c39-9a51-2f1f0f8f6b2e" }
```

* The job runs asynchronously, so the response is `202 Accepted`. `Location` is the URL to poll, and `Retry-After` the seconds to wait before the first poll.

* A job accepts 1–1,000 `queries`.

* Idealo `search-by-term`, `search-by-url`, and `shop-info` accept exactly one query.

* Creating the job charges one credit per query. See [Credits and billing](https://pricepirate.com/docs/en/api/price-data/credits-and-billing.md).

* The response headers report your remaining credits and limits. See [Monitor usage](https://pricepirate.com/docs/en/api/price-data/monitoring-usage.md#usage-headers).

## Poll a job

Poll `GET /api/v2/jobs/{jobId}` until `status` is `completed` or `failed`:

```bash theme={null}
curl https://api-v2.pricepirate.com/api/v2/jobs/<job_id> \
  --header 'x-api-key: <api-key>'
```

While the job is `pending`, the poll answers `202 Accepted` with the same `Location` and `Retry-After: 5` headers. Once the job is `completed` or `failed`, it answers `200`. The body is the same job view either way. HTTP clients that follow `202` + `Location` poll on their own; in your own code, poll every 5 seconds.

| Job `status` | Meaning |
| - | - |
| `pending` | Lookups are running. Finished results already appear in `results`. |
| `completed` | All lookups finished. Check each result's own status. |
| `failed` | The job could not finish. It is refunded in full when you poll it. |

Each entry in `results` has its own `status`:

| Result `status` | Meaning | Charged |
| - | - | - |
| `found` | The lookup returned data. | Yes |
| `not_found` | The product does not exist on that marketplace. | Yes |
| `error` | The lookup failed. `errorCode` tells you why. | No, refunded |

`errorCode` `invalid_query` means the query itself is invalid and fails again on retry. `blocked`, `rate_limited`, `timeout`, `scrape_error`, and `internal_error` are worth retrying in a new job.

For Idealo search jobs, add `?omit_partials=true` to keep pending polls small. `results` stays empty until the job is terminal; progress fields still update.

> [!WARNING]
>
> Results are retained for about an hour after the job completes. Store them as soon as the job is terminal. After that, the poll returns `404`. The job still appears in your [job history](#list-your-jobs), without results.

### Refunds happen on the poll

Error refunds are applied when you poll the job in a terminal status, as JSON or CSV. A job you never poll before its results expire keeps its full charge.

## Export results as CSV

`GET /api/v2/jobs/{jobId}/csv` returns the same job as CSV, with one row per offer:

```bash theme={null}
curl https://api-v2.pricepirate.com/api/v2/jobs/<job_id>/csv?delimiter=%3B \
  --header 'x-api-key: <api-key>' \
  --output job.csv
```

* The export costs no additional credits and settles the job like a JSON poll.
* While the job is `pending`, the export returns `409`.
* Results without offers (`not_found`, `error`) produce no rows. Use JSON to check their status.
* `X-Offer-Rows` reports the number of data rows, so you can tell an empty export from a broken one.
* `delimiter` accepts `,` (default), `;`, or `tab`.
* Files are UTF-8 with a BOM and CRLF line endings.

## List your jobs

`GET /api/v2/jobs` returns every job your account created, newest first, with what it was billed and refunded:

```bash theme={null}
curl "https://api-v2.pricepirate.com/api/v2/jobs?limit=2&settled=true" \
  --header 'x-api-key: <api-key>'
```

```json theme={null}
{
  "jobs": [
    {
      "job_id": "3f6c0a7e-5d1b-4c39-9a51-2f1f0f8f6b2e",
      "source": "idealo",
      "operation": "search-by-gtin",
      "country": "de",
      "query_count": 2,
      "credits": { "billed": 2, "refunded": 1 },
      "settled": true,
      "created_at": "2026-10-14T09:12:03.000Z",
      "settled_at": "2026-10-14T09:12:41.000Z",
      "results": { "found": 1, "not_found": 0, "error": 1 }
    }
  ],
  "next_cursor": "MjAyNi0xMC0xNFQwOToxMjowMy4wMDBafDNmNmMwYTdl"
}
```

* The history keeps jobs after their results expire. It never contains the results themselves.
* `settled` is `true` once the job was polled in a terminal status, or polled after its results expired.
* `results` is `null` when the outcome is unknown: the job was never polled to completion, or only after its results expired.
* Filter with `from`, `to` (ISO 8601), `source`, `operation`, `country`, and `settled`.
* Page with `limit` (1–200, default 50) and `cursor`, using the previous `next_cursor`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.