# ライフタイムバリュー（LTV）データの取得

> 顧客のエンゲージメント期間における長期的な収益ポテンシャルを評価するための LTV データを取得します。
>
> レート制限：1 秒あたり 2 リクエスト。

## OpenAPI

```yaml
/api-specs/export-analytics-api.yaml post /api/v1/client-api/metrics/ltv/
openapi: 3.1.0
info:
  title: Adapty エクスポートアナリティクス API
  version: 1.0.0
  description: |
    Adapty エクスポートアナリティクス API を使用すると、アナリティクスデータを CSV または JSON 形式でエクスポートできます。
    アプリのパフォーマンス指標をより深く分析し、レポートをカスタマイズして、
    時系列のトレンドを分析する柔軟性が得られます。この API を使用することで、詳細なアナリティクスデータを簡単に取得し、
    データインサイトを追跡・共有・改善することができます。
servers:
  - url: https://api-admin.adapty.io
    description: 本番サーバー
security:
  - apikeyAuth: []
paths:
  /api/v1/client-api/metrics/ltv/:
    post:
      summary: ライフタイムバリュー（LTV）データの取得
      description: |-
        顧客のエンゲージメント期間における長期的な収益ポテンシャルを評価するための LTV データを取得します。

        レート制限：1 秒あたり 2 リクエスト。
      operationId: retrieveLTVData
      security:
        - apikeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LTVDataRequest"
            examples:
              basic:
                summary: 基本的な LTV データリクエスト
                value:
                  filters:
                    date:
                      - "2024-01-01"
                      - "2024-12-31"
                    compare_date:
                      - "2023-01-01"
                      - "2023-12-31"
                    offer_category:
                      - introductory
                    store:
                      - app_store
                    country:
                      - us
                    attribution_source:
                      - appsflyer
                    attribution_status:
                      - organic
                    attribution_channel:
                      - social_media
                  period_unit: quarter
                  period_type: renewals
                  segmentation: store_product_id
                  format: csv
      responses:
        "200":
          description: LTV データを正常に取得しました
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LTVDataResponse"
              example:
                revenue:
                  data:
                    - title: Total
                      type: total
                      value: 0
                      values: []
                      cohort_size: 0
                  description: |-
                    <div>LTV (Lifetime Value) is calculated as revenue for the period / number of subscribers on start.
                     It's an actual, not predicted LTV.
                     <a target="_blank" rel="noopener noreferrer" href='https://adapty.io/docs/ltv'> Read more</a>.</div>
                  value: 0
                  unit: USD
                  title: LTV
                proceeds:
                  data:
                    - title: Total
                      type: total
                      value: 0
                      values: []
                      cohort_size: 0
                  description: |-
                    <div>LTV (Lifetime Value) is calculated as revenue for the period / number of subscribers on start.
                     It's an actual, not predicted LTV.
                     <a target="_blank" rel="noopener noreferrer" href='https://adapty.io/docs/ltv'> Read more</a>.</div>
                  value: 0
                  unit: USD
                  title: LTV
                net_revenue:
                  data:
                    - title: Total
                      type: total
                      value: 0
                      values: []
                      cohort_size: 0
                  description: |-
                    <div>LTV (Lifetime Value) is calculated as revenue for the period / number of subscribers on start.
                     It's an actual, not predicted LTV.
                     <a target="_blank" rel="noopener noreferrer" href='https://adapty.io/docs/ltv'> Read more</a>.</div>
                  value: 0
                  unit: USD
                  title: LTV
            text/csv:
              schema:
                type: string
                description: CSV 形式の LTV データ
        "400":
          description: リクエストが不正です
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: 認証されていません
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedError"
        "429":
          description: レート制限を超過しました。API キーごとに 1 秒あたり最大 2 リクエストです。
components:
  schemas:
    LTVDataRequest:
      type: object
      required:
        - filters
      properties:
        filters:
          $ref: "#/components/schemas/MetricsFilters"
        period_unit:
          type: string
          enum:
            - day
            - week
            - month
            - quarter
            - year
          description: アナリティクスデータを集計する時間間隔を指定します
        period_type:
          type: string
          enum:
            - renewals
            - days
          description: 更新回数または日数でデータを分析します
        segmentation:
          type: string
          description: セグメンテーションの基準を設定します
        format:
          type: string
          enum:
            - json
            - csv
          description: エクスポートファイルの形式を指定します
          default: json
    LTVDataResponse:
      type: object
      description: 異なる収益タイプの LTV データを含むレスポンス
      properties:
        revenue:
          $ref: "#/components/schemas/LTVMetric"
          description: 総収益を使用して計算した LTV
        proceeds:
          $ref: "#/components/schemas/LTVMetric"
          description: プロシード（ストア手数料控除後）を使用して計算した LTV
        net_revenue:
          $ref: "#/components/schemas/LTVMetric"
          description: 純収益を使用して計算した LTV
    ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    UnauthorizedError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    MetricsFilters:
      type: object
      required:
        - date
      properties:
        date:
          type: array
          items:
            type: string
          description: チャートデータを取得する日付または期間を入力します
        compare_date:
          type: array
          items:
            type: string
          description: 比較する日付または期間を入力します
        store:
          type: array
          items:
            type: string
          description: 購入が行われたアプリストアでフィルタリングします
        country:
          type: array
          items:
            type: string
          description: 購入が行われた国の 2 文字の国コードでフィルタリングします
        store_product_id:
          type: array
          items:
            type: string
          description: アプリストアのプロダクト固有識別子
        duration:
          type: array
          items:
            type: string
          description: サブスクリプションの期間を指定します
        attribution_source:
          type: array
          items:
            type: string
          description: アトリビューションのソースインテグレーション
        attribution_status:
          type: array
          items:
            type: string
          description: アトリビューションがオーガニックか非オーガニックかを示します
        attribution_channel:
          type: array
          items:
            type: string
          description: トランザクションに至ったマーケティングチャネル
        attribution_campaign:
          type: array
          items:
            type: string
          description: トランザクションをもたらしたマーケティングキャンペーン
        attribution_adgroup:
          type: array
          items:
            type: string
          description: トランザクションをもたらしたアトリビューション広告グループ
        attribution_adset:
          type: array
          items:
            type: string
          description: トランザクションに至ったアトリビューション広告セット
        attribution_creative:
          type: array
          items:
            type: string
          description: 効果測定のために追跡される広告またはキャンペーン内の特定のビジュアルまたはテキスト要素
        offer_category:
          type: array
          items:
            type: string
          description: データを取得するオファーカテゴリを指定します
        offer_type:
          type: array
          items:
            type: string
          description: データを取得するオファータイプを指定します
        offer_id:
          type: array
          items:
            type: string
          description: データを取得する特定のオファーを指定します
    LTVMetric:
      type: object
      description: コホートデータと計算を含む個別の LTV 指標
      properties:
        data:
          type: array
          description: 異なるコホートの LTV データポイントの配列
          items:
            $ref: "#/components/schemas/LTVData"
        description:
          type: string
          description: LTV の計算方法を説明する HTML の説明文
        value:
          type: number
          description: 全体的な LTV 値
        unit:
          type: string
          description: 測定単位（通常は 'USD'）
        title:
          type: string
          description: この LTV 指標の表示タイトル
    LTVData:
      type: object
      description: 特定のコホートの個別 LTV データポイント
      properties:
        title:
          type: string
          description: この LTV データポイントの表示タイトル
        type:
          type: string
          description: LTV データのタイプ（集計データの場合は 'total'）
        value:
          type: number
          description: このコホートの LTV 値
        values:
          type: array
          description: 期間別 LTV 値の配列
          items:
            type: object
        cohort_size:
          type: integer
          description: このコホートのユーザー数
  securitySchemes:
    apikeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        API リクエストは、シークレット API キーを Authorization ヘッダーとして使用して認証する必要があります。
        API キーはアプリ設定で確認できます。形式は `Api-Key {YOUR_SECRET_API_KEY}` です。
        例：`Api-Key secret_live_...`
```
