> ## 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.

# 実行レコード取得

> 実行レコードをページング。JSON/JSONL/CSV 対応。

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

認証：APIキー必須（`Authorization: Bearer <API Key>`）。

実行が出力したレコードをページング。`format` は `json`（既定、ページネーション付き）、`jsonl`、`csv`。`fields` はカンマ区切り列指定。

実行中でも読める。その時点までの分が返り `pagination.total` は増え続ける。全件は終端待ち。`partial` は部分成功または取消時 `true`。それらのレコードは有効で課金済み。

自分が開始した実行のみ読める。他アカウントの `run_id` と存在しない `run_id` はどちらも `404`。

## リクエスト

### パスパラメータ

<ParamField path="run_id" type="string" required>
  実行 id。
</ParamField>

### クエリパラメータ

<ParamField query="offset" type="integer" default="0">
  ページネーションオフセット。

  範囲 ≥ 0。
</ParamField>

<ParamField query="limit" type="integer" default="100">
  Page size, max 10000.

  範囲 1〜10000。
</ParamField>

<ParamField query="format" type="string" default="json">
  出力形式。`json` はページネーション付きエンベロープ。`jsonl` は 1 行 1 レコード。`csv` は表形式。

  Values: `json` / `jsonl` / `csv`.
</ParamField>

<ParamField query="fields" type="string">
  カンマ区切りフィールド名。これらの列のみ。例: `title,price,url`。
</ParamField>

### リクエスト例

```bash theme={null}
curl \
  -H "Authorization: Bearer $OCTOPARSE_API_KEY" \
  "https://api-datahub.octoparse.com/v1/runs/run_c62bc0fb8df2/records?offset=0&limit=100"
```

## レスポンス

### 200 成功

```json theme={null}
{
  "data": {
    "run_id": "run_c62bc0fb8df2",
    "dataset_id": "ds_0bd5345d13d0",
    "records": [
      {
        "review_id": "103c9e-0000"
      },
      {
        "review_id": "103c9e-0001"
      }
    ],
    "partial": false,
    "pagination": {
      "offset": 0,
      "limit": 2,
      "count": 2,
      "total": 20,
      "has_more": true
    }
  }
}
```

`jsonl`/`csv` はエンベロープなし生テキスト。ページネーションは有効。

ペイロードは `data` に包まれます。フィールド:

<ResponseField name="run_id" type="string">
  実行 id。
</ResponseField>

<ResponseField name="dataset_id" type="string" required>
  結果を保持するデータセット。
</ResponseField>

<ResponseField name="records" type="object[]" required>
  レコード配列。各要素は `output_schema.record` に従う。
</ResponseField>

<ResponseField name="partial" type="boolean">
  部分成功または取消か。
</ResponseField>

<ResponseField name="pagination" type="object" required>
  Pagination object.

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

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

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

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

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

### エラー

| HTTP | `code`          | `category`  | Description               |
| ---- | --------------- | ----------- | ------------------------- |
| 401  | `unauthorized`  | `forbidden` | API キー欠落または無効。            |
| 404  | `run-not-found` | `not_found` | 実行が存在しないか、現在のアカウント開始ではない。 |

エラー応答は `{"error": {code, category, message, retryable}}` です。<a href="/docs/jp/datahub/api/reference/introduction#errors">エラー</a> を参照。

## クライアントライブラリ

<CodeGroup>
  ```python Python theme={null}
  # Auto-paginate all records
  for record in client.iterate_records("run_c62bc0fb8df2", batch=500):
      print(record)

  # One page
  page = client.get_records("run_c62bc0fb8df2", offset=0, limit=100, fields="title,price")

  # Export the full result as text (jsonl / csv)
  text = client.export_records("run_c62bc0fb8df2", format="csv")
  ```

  ```js JavaScript theme={null}
  // Auto-paginate all records
  for await (const record of client.iterateRecords("run_c62bc0fb8df2", { batch: 500 })) {
    console.log(record);
  }

  // One page
  const page = await client.getRecords("run_c62bc0fb8df2", { offset: 0, limit: 100, fields: "title,price" });

  // Export the full result as text (jsonl / csv)
  const text = await client.exportRecords("run_c62bc0fb8df2", "csv");
  ```
</CodeGroup>
