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

# Ottieni un’esecuzione

> Leggi stato, progresso, errore, usage e fatturazione dell’esecuzione. Supporta long polling.

**`GET`** `https://api-datahub.octoparse.com/v1/runs/{run_id}`

Autenticazione: API key obbligatoria (`Authorization: Bearer <API Key>`).

Stato, progresso, oggetto errore, riferimento upstream, usage e fatturazione. Con `wait` > 0 il server tiene la connessione fino a stato terminale o timeout. Se non è ancora terminale, richiama con lo stesso `wait`. Non fare poll frequenti con `wait=0`.

Puoi leggere solo le run che hai avviato. Il `run_id` di un altro account e un `run_id` mancante restituiscono entrambi `404`. I campi marcati `sensitive` nel contratto di input sono redatti in echo: plaintext write-only che nemmeno lo starter può rileggere.

## Richiesta

### Parametri di percorso

<ParamField path="run_id" type="string" required>
  ID del run.
</ParamField>

### Parametri di query

<ParamField query="wait" type="number" default="0">
  Long-poll seconds, `0–60`. Predefinito `0` restituisce immediately.

  Intervallo da 0 a 60.
</ParamField>

### Esempio di richiesta

```bash theme={null}
curl \
  -H "Authorization: Bearer $OCTOPARSE_API_KEY" \
  "https://api-datahub.octoparse.com/v1/runs/run_c62bc0fb8df2?wait=60"
```

## Risposta

### 200 successo

```json theme={null}
{
  "data": {
    "run_id": "run_c62bc0fb8df2",
    "namespace": "carol",
    "app_name": "probe-b",
    "app_version": "0.1.0",
    "build_id": null,
    "run_kind": "production",
    "state": "SUCCEEDED",
    "input": {
      "product": "p-now"
    },
    "progress": {
      "done": 20,
      "total": null,
      "status_text": null
    },
    "dataset_id": "ds_0bd5345d13d0",
    "partial": false,
    "cancel_requested": false,
    "triggered_by": "api",
    "upstream_ref": null,
    "created_at": "2026-09-15T07:45:40.411993+00:00",
    "started_at": "2026-09-15T07:45:40.419610+00:00",
    "first_started_at": "2026-09-15T07:45:40.419610+00:00",
    "finished_at": "2026-09-15T07:45:40.822250+00:00",
    "usage": {
      "metrics": {
        "records_collected": 20
      },
      "duration_ms": 402
    },
    "billing": {
      "events": [
        {
          "event": "record",
          "label": "One record",
          "qty": 20.0,
          "unit_price": 0.001,
          "amount": 0.02,
          "unit_size": null,
          "raw_qty": null
        }
      ],
      "total": 0.02,
      "currency": "USD",
      "charged": true
    },
    "error": null,
    "sample_records": null,
    "warnings": []
  }
}
```

I campi corrispondono alla risposta di <a href="/docs/it/datahub/api/reference/runs/start-run">Start a run</a>.

Il payload è wrappato in `data`. Campi:

<ResponseField name="run_id" type="string" required>
  —
</ResponseField>

<ResponseField name="namespace" type="string">
  —
</ResponseField>

<ResponseField name="app_name" type="string">
  —
</ResponseField>

<ResponseField name="app_version" type="string">
  —
</ResponseField>

<ResponseField name="build_id" type="string">
  —
</ResponseField>

<ResponseField name="run_kind" type="string">
  —
</ResponseField>

<ResponseField name="state" type="enum" required>
  Valori: `PENDING` / `QUEUED` / `RUNNING` / `SUCCEEDED` / `PARTIALLY_SUCCEEDED` / `FAILED` / `CANCELLED` / `EXPIRED`.
</ResponseField>

<ResponseField name="input" type="object">
  —
</ResponseField>

<ResponseField name="progress" type="object">
  —

  <Expandable title="fields">
    <ResponseField name="done" type="integer">
      —
    </ResponseField>

    <ResponseField name="total" type="integer">
      —
    </ResponseField>

    <ResponseField name="status_text" type="string">
      —
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="dataset_id" type="string">
  —
</ResponseField>

<ResponseField name="partial" type="boolean">
  —
</ResponseField>

<ResponseField name="cancel_requested" type="boolean">
  `true` mentre l'annullamento è stato richiesto e il run è ancora in fase di chiusura (arresto cooperativo / recupero dei risultati parziali). Sempre `false` negli stati terminali (normalizzato lato server), quindi i client non devono ricavarlo da `state`.
</ResponseField>

<ResponseField name="triggered_by" type="string">
  —
</ResponseField>

<ResponseField name="upstream_ref" type="string">
  —
</ResponseField>

<ResponseField name="created_at" type="string">
  —
</ResponseField>

<ResponseField name="started_at" type="string">
  —
</ResponseField>

<ResponseField name="first_started_at" type="string">
  Quando un worker ha claimato la run la prima volta. A differenza di `started_at` non viene mai riscritto al retry: ancora per il tempo in coda: queued = `first_started_at - created_at`, wall time totale = `finished_at - first_started_at`. Derivare il tempo in coda da `started_at` conta i tentativi precedenti come queueing. `null` solo per run mai claimate.
</ResponseField>

<ResponseField name="finished_at" type="string">
  —
</ResponseField>

<ResponseField name="usage" type="object">
  Metering usage oggettivo: quanto ha fatto la run. Separato dalla fatturazione; è ciò che le evaluation confrontano.

  <Expandable title="fields">
    <ResponseField name="metrics" type="object">
      —
    </ResponseField>

    <ResponseField name="duration_ms" type="integer">
      —
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="billing" type="object">
  Registro di fatturazione = utilizzo × prezzi × regole di fatturazione: quanto viene addebitato.

  <Expandable title="fields">
    <ResponseField name="events" type="object[]">
      —

      <Expandable title="fields">
        <ResponseField name="event" type="string" required>
          —
        </ResponseField>

        <ResponseField name="label" type="string">
          —
        </ResponseField>

        <ResponseField name="qty" type="number" required>
          —
        </ResponseField>

        <ResponseField name="unit_price" type="number" required>
          —
        </ResponseField>

        <ResponseField name="amount" type="number" required>
          —
        </ResponseField>

        <ResponseField name="unit_size" type="integer">
          —
        </ResponseField>

        <ResponseField name="raw_qty" type="number">
          —
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total" type="number">
      —
    </ResponseField>

    <ResponseField name="currency" type="string">
      —
    </ResponseField>

    <ResponseField name="charged" type="boolean">
      —
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="error" type="object">
  —

  <Expandable title="fields">
    <ResponseField name="code" type="string" required>
      —
    </ResponseField>

    <ResponseField name="category" type="string">
      —
    </ResponseField>

    <ResponseField name="message" type="string" required>
      —
    </ResponseField>

    <ResponseField name="retryable" type="boolean">
      —
    </ResponseField>

    <ResponseField name="retry_after" type="number">
      —
    </ResponseField>

    <ResponseField name="item_index" type="integer">
      —
    </ResponseField>

    <ResponseField name="details" type="object[]">
      —
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="sample_records" type="object[]">
  —
</ResponseField>

<ResponseField name="warnings" type="object[]">
  —

  <Expandable title="fields">
    <ResponseField name="code" type="string" required>
      —
    </ResponseField>

    <ResponseField name="event" type="string">
      —
    </ResponseField>

    <ResponseField name="detail" type="object">
      —
    </ResponseField>

    <ResponseField name="count" type="integer">
      —
    </ResponseField>

    <ResponseField name="updated_at" type="string">
      —
    </ResponseField>
  </Expandable>
</ResponseField>

### Errori

| HTTP | `code`          | `category`  | Descrizione                                                    |
| ---- | --------------- | ----------- | -------------------------------------------------------------- |
| 401  | `unauthorized`  | `forbidden` | API key mancante o non valida.                                 |
| 404  | `run-not-found` | `not_found` | La run non esiste o non è stata avviata dall’account corrente. |

Le risposte di errore usano `{"error": {code, category, message, retryable}}`. Vedi <a href="/docs/it/datahub/api/reference/introduction#errors">Errori</a>.

## Librerie client

<CodeGroup>
  ```python Python theme={null}
  run = client.get_run("run_c62bc0fb8df2", wait=60)
  print(run["state"], run["progress"], run["billing"]["total"])
  ```

  ```js JavaScript theme={null}
  const run = await client.getRun("run_c62bc0fb8df2", { wait: 60 });
  console.log(run.state, run.progress, run.billing.total);
  ```
</CodeGroup>
