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

# 請求集計

> 期間支出を日・App・資格情報で内訳。

**`GET`** `https://api-datahub.octoparse.com/v1/billing`

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

期間にいくら・どこで使ったか。アカウント情報エンドポイントとは独立。

時間範囲の語彙は <a href="/docs/jp/datahub/api/reference/runs/list-runs">実行一覧</a>: `created_from` / `created_to` は実行**開始**時刻基準の inclusive/exclusive ISO-8601 絶対時刻。同じ境界を実行一覧に渡せばグループ合計の背後を掘れる。`tz_offset` は日バケットのローカル日だけ決め、金額や絶対範囲は変えない。

集計はデータ料金のみ。日グループは照合しやすい昇順、App・資格情報は金額降順で最大が先。

`credential` 内訳は「自分の各キーがいくら使ったか」。キーは機微でない安定資格情報 id で、実行一覧の `credential` フィルタと同じ値。スコープは常に自分のアカウント。

## リクエスト

### クエリパラメータ

<ParamField query="group_by" type="string" default="day">
  内訳次元: `day`（既定）/ `data_app` / `credential`。
</ParamField>

<ParamField query="created_from" type="string">
  開始（inclusive）。省略で最古から。
</ParamField>

<ParamField query="created_to" type="string">
  終了（exclusive）。省略で現在まで。
</ParamField>

<ParamField query="tz_offset" type="integer" default="0">
  日バケットの UTC からの分オフセット。中国標準時は `480`。既定 `0` は UTC 日。固定オフセットのみ（DST なし）。掘り下げの `created_from` / `created_to` も同オフセット。範囲 -720〜840。
</ParamField>

### リクエスト例

```bash theme={null}
curl \
  -H "Authorization: Bearer $OCTOPARSE_API_KEY" \
  "https://api-datahub.octoparse.com/v1/billing?group_by=day&created_from=2026-09-01T00:00:00%2B00:00&created_to=2026-10-01T00:00:00%2B00:00&tz_offset=0"
```

## レスポンス

### 200 成功

```json theme={null}
{
  "data": {
    "total": 0.08,
    "currency": "USD",
    "group_by": "day",
    "groups": [
      {
        "day": "2026-07-01",
        "namespace": null,
        "app_name": null,
        "credential": null,
        "credential_name": null,
        "runs": 2,
        "amount": 0.04
      }
    ]
  }
}
```

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

<ResponseField name="total" type="number">
  期間合計。各グループ `amount` 合計と一致。
</ResponseField>

<ResponseField name="currency" type="string">
  通貨。
</ResponseField>

<ResponseField name="group_by" type="string">
  実際に使われた次元。
</ResponseField>

<ResponseField name="groups" type="object[]">
  グループ行。全次元フィールドあり、未使用は `null`。

  <Expandable title="fields">
    <ResponseField name="day" type="string">
      `group_by=day` のキー。`YYYY-MM-DD`。
    </ResponseField>

    <ResponseField name="namespace" type="string">
      `group_by=data_app` 時の発行者名。
    </ResponseField>

    <ResponseField name="app_name" type="string">
      `group_by=data_app` 時の App 名。
    </ResponseField>

    <ResponseField name="credential" type="string">
      `group_by=credential` 時の安定資格情報 id。
    </ResponseField>

    <ResponseField name="credential_name" type="string">
      資格情報表示名（ある場合）。
    </ResponseField>

    <ResponseField name="runs" type="integer">
      グループ内実行数。
    </ResponseField>

    <ResponseField name="amount" type="number">
      グループのデータ料金合計。
    </ResponseField>
  </Expandable>
</ResponseField>

### エラー

| HTTP | `code`          | `category`      | Description    |
| ---- | --------------- | --------------- | -------------- |
| 400  | `invalid-input` | `invalid_input` | パラメータが無効。      |
| 401  | `unauthorized`  | `forbidden`     | API キー欠落または無効。 |

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

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

<CodeGroup>
  ```python Python theme={null}
  print(client.billing(group_by="data_app", tz_offset=0))
  ```

  ```js JavaScript theme={null}
  console.log(await client.billing({ groupBy: "data_app", tzOffset: 0 }));
  ```
</CodeGroup>
