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

# ストリームブループリント

> ビデオ、オーディオ、ライブストリーム、リアルタイムデータ転送の請求のためにストリーミングデータ消費を追跡します。

## ユースケース

ストリームブループリントがサポートする一般的なシナリオを探ります：

<CardGroup cols={2}>
  <Card title="Video Platforms" icon="video">
    ビデオ帯域幅の消費とストリーミング品質に基づいて顧客に請求します。
  </Card>

  <Card title="Music Streaming" icon="music">
    サブスクリプション階層ごとにユーザーのオーディオストリーミング使用量を追跡します。
  </Card>

  <Card title="Live Events" icon="signal-stream">
    ライブストリームの使用量を監視し、帯域幅使用量に応じて課金します。
  </Card>

  <Card title="Real-Time Data" icon="wave-pulse">
    IoT およびテレメトリアプリケーション向けのリアルタイムデータ転送を追跡します。
  </Card>
</CardGroup>

<Info>
  ビデオ/オーディオストリーミングプラットフォーム、ライブストリーミングサービス、リアルタイムデータアプリケーションに最適です。
</Info>

## クイックスタート

顧客によって消費されたストリーミングバイトを追跡します：

<Steps>
  <Step title="Install the SDK">
    ```bash theme={null}
    npm install @dodopayments/ingestion-blueprints
    ```
  </Step>

  <Step title="Get Your API Keys">
    * **Dodo Payments API Key**: [Dodo Payments Dashboard](https://app.dodopayments.com/developer/api-keys) から取得します
  </Step>

  <Step title="Create a Meter">
    お使いの [Dodo Payments Dashboard](https://app.dodopayments.com/) でメーターを作成します:

    * **Event Name**: `stream_consumption`（または任意の名前）
    * **Aggregation Type**: `sum` を使用してストリーミングされた合計バイト数を追跡します
    * **Over Property**: `bytes` を使用して帯域幅使用量に基づいて課金します
  </Step>

  <Step title="Track Stream Usage">
    <CodeGroup>
      ```javascript Video Streaming theme={null}
      import { Ingestion, trackStreamBytes } from '@dodopayments/ingestion-blueprints';

      const ingestion = new Ingestion({
        apiKey: process.env.DODO_PAYMENTS_API_KEY,
        environment: 'test_mode',
        eventName: 'stream_consumption'
      });

      // Track video stream consumption
      await trackStreamBytes(ingestion, {
        customerId: 'customer_123',
        bytes: 10485760, // 10MB
        metadata: {
          stream_type: 'video',
        }
      });
      ```
    </CodeGroup>
  </Step>
</Steps>

## 設定

### 取り込み設定

<ParamField path="apiKey" type="string" required>
  ダッシュボードから取得した Dodo Payments API キー。
</ParamField>

<ParamField path="environment" type="string" required>
  環境モード: `test_mode` または `live_mode`。
</ParamField>

<ParamField path="eventName" type="string" required>
  メーター設定に一致するイベント名。
</ParamField>

### ストリームバイト追跡オプション

<ParamField path="customerId" type="string" required>
  課金の帰属先となる顧客ID。
</ParamField>

<ParamField path="bytes" type="number">
  ストリームで消費されたバイト数。帯域幅ベースの課金に必要です。
</ParamField>

<ParamField path="metadata" type="object">
  ストリームタイプ、品質、sessionId など、ストリームに関する任意のメタデータ。
</ParamField>

## ベストプラクティス

<Tip>
  **チャンク単位で追跡**: 長時間のストリームでは、全体が完了するのを待たずにチャンク単位で使用量を追跡します。
</Tip>

<Warning>
  **正確なバイト数の計測**: 合計帯域幅に対して請求する場合は、オーバーヘッド（ヘッダー、プロトコルのオーバーヘッドなど）を含めたバイト数になるようにしてください。
</Warning>
