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

# 广告互动时间分析

> 广告互动时间分析（CTR、CVR、点击数、转化数、留存数）。与`/v1/tk-ads/top_ads_detail`配合使用

<div className="inline-flex items-center gap-2 px-4 py-2 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg">
  <span className="text-base">🪙</span>
  <span className="text-sm font-medium text-yellow-900 dark:text-yellow-100"><span className="font-semibold">2 credits</span><span className="text-yellow-700 dark:text-yellow-300 ml-1">每次请求</span></span>
</div>

## Copy for AI

<div className="my-6 rounded-xl border border-gray-200 bg-gray-50 p-5 dark:border-gray-800 dark:bg-gray-900/40">
  <div className="min-w-0">
    <p className="text-base font-semibold text-gray-900 dark:text-gray-100">🤖 让 AI 帮你写调用代码</p>
    <p className="mt-1 text-sm text-gray-700 dark:text-gray-300">点击按钮复制一段结构化提示词，可直接交给 ChatGPT、Claude 或其他 AI 助手生成接口调用代码。</p>
  </div>

  <div className="mt-4">
    <button
      type="button"
      className="inline-flex items-center gap-2 rounded-md border border-emerald-300 bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-800 hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-100 dark:hover:bg-emerald-900/50"
      onClick={() => navigator.clipboard.writeText(`我需要调用以下 KeyAPI 接口，请根据提供的接口信息生成一份可直接运行的 Python 示例代码。

## 接口信息

Endpoint: GET https://api.keyapi.ai/v1/tk-ads/interactive_time_analysis
Summary: 广告互动时间分析

Required Headers:
- Authorization: Bearer <YOUR_API_KEY>

Parameters:
- material_id (Required): 无描述. Example: 7552078920880619527
- metric (Optional): 可选值（不支持多选）：retain_ctr、retain_cvr、click_cnt、convert_cnt、play_retain_cnt.


## 代码要求

- 使用 Python \`requests\` 库
- 提供完整、可直接运行的示例
- 处理 HTTP 请求异常、超时以及非 2xx 响应
- 处理 JSON 解析异常
- 示例参数优先使用接口信息中提供的 Example
- 保持代码简洁，避免不必要的封装和复杂设计
`)}
    >
      ✨ 复制给 AI
    </button>
  </div>
</div>


## OpenAPI

````yaml zh/tiktok-ads-library.zh.openapi.json GET /v1/tk-ads/interactive_time_analysis
openapi: 3.0.1
info:
  title: KeyAPI 文档
  description: tiktok-ads-library API 的中文参考文档，包含接口用途、参数说明、响应状态和示例结构。
  version: 1.0.0
servers:
  - url: https://api.keyapi.ai
    description: Production-KeyAPI
security: []
tags: []
paths:
  /v1/tk-ads/interactive_time_analysis:
    get:
      tags: []
      summary: 广告互动时间分析
      description: 广告互动时间分析（CTR、CVR、点击数、转化数、留存数）。与`/v1/tk-ads/top_ads_detail`配合使用
      parameters:
        - name: material_id
          in: query
          description: ''
          required: true
          example: '7552078920880619527'
          schema:
            type: string
            example: '7552078920880619527'
        - name: metric
          in: query
          description: >-
            可选值（不支持多选）：retain_ctr、retain_cvr、click_cnt、convert_cnt、play_retain_cnt


            retain_ctr = 点击率(CTR)度量的是每一秒在观看时 点击了广告的观看者所占的百分比。计 算方法是:点击次数除以播放次数。

            retain_cvr = 转化率(CVR)度量的是在视频中的每一 秒发生的转化(如关注、下载或购买) 所占的百分比。计算方法是:转化次数
            除以互动次数。

            click_cnt = 点击数：指该秒内广告获得的点击次数。

            convert_cnt = 转化量：指在该秒产生的转化次数。

            play_retain_cnt = 留存数：指在该秒仍在观看的用户数量。
          required: false
          schema:
            type: string
            enum:
              - retain_ctr
              - retain_cvr
              - click_cnt
              - convert_cnt
              - play_retain_cnt
            default: retain_ctr
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      analysis:
                        type: array
                        items:
                          type: string
                      highlight:
                        type: array
                        items:
                          type: string
                        description: >-
                          "高光帧"是指视频在特定指标上表现出色的时间段，这意味着更高价值，我们推荐将相应时间段用作视频开头的预览。对于此视频，`metric
                          = retain_ctr` 时表示：CTR的高光帧发生在第 1 秒、第 9 秒和第 13 秒。`metric
                          = retain_cvr` 时表示：CVR的高光帧发生在第 1 秒、第 9 秒和第 13 秒。
                    required:
                      - highlight
                      - analysis
                required:
                  - data
              example:
                code: 0
                message: success
                data:
                  analysis:
                    - second: 0
                      value: 0.05674191580231849
                    - second: 1
                      value: 1
                    - second: 2
                      value: 0.3881286498736163
                    - second: 3
                      value: 0.23097707661466052
                    - second: 4
                      value: 0.16935413579708883
                    - second: 5
                      value: 0.1273424562015166
                    - second: 6
                      value: 0.1087771289113571
                    - second: 7
                      value: 0.10790551730149045
                    - second: 8
                      value: 0.09221650832389088
                    - second: 9
                      value: 0.0956157936023708
                    - second: 10
                      value: 0.08785845027455766
                    - second: 11
                      value: 0.0784450448879979
                    - second: 12
                      value: 0.06545803190098493
                    - second: 13
                      value: 0.06833435021354484
                    - second: 14
                      value: 0.06554519306197158
                    - second: 15
                      value: 0.11278654231674365
                  duration: 16
                  highlight:
                    - 1
                    - 9
                    - 13
                requestId: 32bc651e-3d88-4663-8fed-75e9a97782d7
          headers: {}
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '402':
          $ref: '#/components/responses/402'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
      deprecated: false
      security:
        - JWT Bearer: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl --request GET \
              --url 'https://api.keyapi.ai/v1/tk-ads/interactive_time_analysis?material_id=7552078920880619527&metric=retain_ctr' \
              --header 'Authorization: Bearer <YOUR_API_KEY>'
        - lang: python
          label: Python
          source: |-
            import requests

            response = requests.get(
                'https://api.keyapi.ai/v1/tk-ads/interactive_time_analysis',
                params={"material_id":"7552078920880619527","metric":"retain_ctr"},
                headers={'Authorization': 'Bearer <YOUR_API_KEY>'}
            )
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: >-
            const params = new
            URLSearchParams({"material_id":"7552078920880619527","metric":"retain_ctr"});


            const response = await
            fetch(`https://api.keyapi.ai/v1/tk-ads/interactive_time_analysis?${params}`,
            {
              method: 'GET',
              headers: { 'Authorization': 'Bearer <YOUR_API_KEY>' }
            });

            const data = await response.json();

            console.log(data);
components:
  responses:
    '400':
      description: Bad Request
      content:
        application/json:
          schema:
            type: object
            example:
              code: 400
              data: null
              message: 'Missing required parameter: handle'
    '401':
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            example:
              code: 401
              data: null
              message: apiKey is null
    '402':
      description: Payment Required
      content:
        application/json:
          schema:
            type: object
            example:
              code: 402
              data: null
              message: apiKey quota is not enough
    '429':
      description: Too Many Requests
      content:
        application/json:
          schema:
            type: object
            example:
              code: 429
              data: null
              message: qps limit exceeded
    '500':
      description: Internal Server Error
      content:
        application/json:
          schema:
            type: object
            example:
              code: 500
              data: null
              message: Internal server error
  securitySchemes:
    JWT Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |-
        接口鉴权凭证。请在请求 Header 中传入 `Authorization: Bearer <YOUR_API_KEY>`。
        可在 [Dashboard](https://keyapi.ai/app/dashboard) 获取你的 API Key。

````