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

# Top Ads Insights

> Retrieve insights on top-performing TikTok ads, including ad creative types, engagement rates, and industry distribution.

<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">per request</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">🤖 Why Code When AI Can Do It For You?</p>
    <p className="mt-1 text-sm text-gray-700 dark:text-gray-300">Stop writing code like it's 1970! Let AI do the heavy lifting - click the sparkles to copy a perfectly formatted prompt for ChatGPT, Claude, or your favorite AI assistant.</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(`I want to make an API call to https://api.keyapi.ai/v1/tiktok/insights/ads.

Please help me write code to make this API call and handle the response appropriately. Include error handling and best practices.

Here are the details:

Endpoint: GET https://api.keyapi.ai/v1/tiktok/insights/ads

Description: Retrieve insights on top-performing TikTok ads, including ad creative types, engagement rates, and industry distribution.

Required Headers:
--header 'Authorization: Bearer <YOUR_API_KEY>'

Parameters:
- search_keyword (Optional): Search keywords
Value rule: FALSE (string type) = do not perform the search; non-empty string = perform the search according to the keyword. Example: FALSE
- order_by (Optional): Type (choose one option)
Recommendation = for_you
Exposure = impression
Click-through rate = ctr
2-second completion rate = play_2s_rate
6-second completion rate = play_6s_rate
CVR = cvr
Number of likes = like. Example: for_you
- page (Optional): Pagination page number, used to specify the target page number of the query results. Example: 1
- limit (Optional): The number of data items per page in pagination, which is used to specify the maximum number of results returned in a single query. The value range is 1 to 20. If it exceeds the maximum value, it will be automatically handled as 20.. Example: 20
- period (Optional): Time range for querying data
Optional valid values: 7 (last 7 days), 30 (last 30 days), 120 (last 120 days). Example: 7
- region (Optional): Country/region code, example: US. Example: nothing
- industry (Optional): Industry ID, which can be found in the Hot Trends - Industry Classification Mapping. Example: nothing
- objective (Optional): Delivery Targets (Optional)
Default value "nothing" means no delivery target is selected.
Number of visits = 1
App installations = 2
Conversions = 3
Video views = 4
Reach = 5
Lead generation = 8
Product sales = 14. Example: nothing
- ad_language (Optional): Advertising language (optional)
The default value "nothing" means not selecting any advertising language.
English = en
Spanish = es
Arabic = ar
Vietnamese = vi
Thai = th
German = de
Indonesian = id
Portuguese = pt
French = fr
Malay = ms
Dutch = n
Japanese = ja
Italian = it
Romanian = ro
Traditional Chinese = zh-Hant
Korean = ko. Example: nothing
- ad_format (Optional): Ad style (choose one option)
The default value "nothing" means not selecting any condition.
Spark Ads = 1
Non-Spark Ads = 2. Example: nothing
- like (Optional): Number of likes (optional)
The default value "nothing" means no condition is selected.
Top 1-20% = 1
Top 21-40% = 2
Top 41-60% = 3
Top 61-80% = 4
Top 81-100% = 5. Example: nothing

Example Response:
{
"code": 0,
"message": "success",
"data": {
"materials": [
  {
    "ad_title": "หมดเก่งมาก",
    "brand_name": "",
    "cost": 2,
    "ctr": 0.89,
    "favorite": false,
    "id": "7599496668887564304",
    "industry_key": "label_23132000000",
    "is_search": true,
    "like": 58400,
    "objective_key": "campaign_objective_video_view",
    "tag": 2,
    "video_info": {
      "vid": "v29044g50000d4sn397og65m159dbpqg",
      "duration": 33.8,
      "cover": "https://p16-sign-sg.tiktokcdn.com/tos-alisg-p-0037/oMaUBL5lEVpCYT7IcAPQ5cCd1ixAZiEBs2aIV~tplv-noop.image?dr=18692&refresh_token=754132a5&x-expires=1770134518&x-signature=Y2HoCVgbuaqkcxIQShxr1oNUYUM%3D&t=9276707c&ps=14f1eb3e&shp=9e36835a&shcp=317596d8&idc=my&VideoID=v29044g50000d4sn397og65m159dbpqg",
      "video_url": {
        "720p": "https://v16m-default.tiktokcdn.com/437306c551d75065fac84cd69e613e83/69821bf6/video/tos/alisg/tos-alisg-pve-0037c001/oQGT2QpiVYDaaBLEdVQ1l56FIQ7C5EExABPic/?a=0&bti=NTU4QDM1NGA%3D&ch=0&cr=0&dr=0&lr=tiktok_business&cd=0%7C0%7C0%7C0&cv=1&br=2456&bt=1228&cs=0&ds=3&ft=cApXJCz7ThWHEWo.1GZmo0P&mime_type=video_mp4&qs=0&rc=PDhoOTYzMzw6Zjk0NzhoZUBpanNnOHA5cjxxNzMzODczNUBeXzAwMDA2X2AxMi0wYGM1YSNuXzYuMmQ0MHBhLS1kMTZzcw%3D%3D&vvpl=1&l=202602031801244A1B2C464168A5C8DBB2&btag=e00088000"
      },
      "width": 576,
      "height": 1024
    }
  }
],
"pagination": {
  "has_more": true,
  "page":
... (truncated)`)}
    >
      <span>✨</span>
      <span>Copy for AI</span>
    </button>
  </div>
</div>


## OpenAPI

````yaml en/tiktok.openapi.json GET /v1/tiktok/insights/ads
openapi: 3.0.1
info:
  title: Tiktok API english documentation
  description: >-
    The english reference documentation of the Tiktok API includes the
    interface's purpose, parameter description, response status, and sample
    structure.
  version: 1.0.0
servers:
  - url: https://api.keyapi.ai
    description: Production
security: []
tags:
  - name: TikTok Influencer
  - name: TikTok Shop
  - name: TikTok Content
  - name: TikTok Intelligence
paths:
  /v1/tiktok/insights/ads:
    get:
      tags:
        - TikTok Intelligence
      summary: Top Ads Insights
      description: >-
        Retrieve insights on top-performing TikTok ads, including ad creative
        types, engagement rates, and industry distribution.
      operationId: get_api_v3_realtime_insights_top_ads_list
      parameters:
        - name: search_keyword
          in: query
          description: >-
            Search keywords

            Value rule: FALSE (string type) = do not perform the search;
            non-empty string = perform the search according to the keyword
          required: false
          schema:
            type: string
            example: 'FALSE'
            default: 'FALSE'
          example: 'FALSE'
        - name: order_by
          in: query
          description: |-
            Type (choose one option)
            Recommendation = for_you
            Exposure = impression
            Click-through rate = ctr
            2-second completion rate = play_2s_rate
            6-second completion rate = play_6s_rate
            CVR = cvr
            Number of likes = like
          required: false
          schema:
            type: string
            example: for_you
            default: for_you
          example: for_you
        - name: page
          in: query
          description: >-
            Pagination page number, used to specify the target page number of
            the query results
          required: false
          schema:
            type: string
            example: '1'
            default: '1'
          example: '1'
        - name: limit
          in: query
          description: >-
            The number of data items per page in pagination, which is used to
            specify the maximum number of results returned in a single query.
            The value range is 1 to 20. If it exceeds the maximum value, it will
            be automatically handled as 20.
          required: false
          schema:
            type: string
            example: '20'
            default: '20'
          example: '20'
        - name: period
          in: query
          description: >-
            Time range for querying data

            Optional valid values: 7 (last 7 days), 30 (last 30 days), 120 (last
            120 days)
          required: false
          schema:
            type: string
            example: '7'
            default: '7'
          example: '7'
        - name: region
          in: query
          description: 'Country/region code, example: US'
          required: false
          schema:
            type: string
            example: nothing
            default: nothing
          example: nothing
        - name: industry
          in: query
          description: >-
            Industry ID, which can be found in the Hot Trends - Industry
            Classification Mapping
          required: false
          schema:
            type: string
            example: nothing
            default: nothing
          example: nothing
        - name: objective
          in: query
          description: |-
            Delivery Targets (Optional)
            Default value "nothing" means no delivery target is selected.
            Number of visits = 1
            App installations = 2
            Conversions = 3
            Video views = 4
            Reach = 5
            Lead generation = 8
            Product sales = 14
          required: false
          schema:
            type: string
            example: nothing
            default: nothing
          example: nothing
        - name: ad_language
          in: query
          description: >-
            Advertising language (optional)

            The default value "nothing" means not selecting any advertising
            language.

            English = en

            Spanish = es

            Arabic = ar

            Vietnamese = vi

            Thai = th

            German = de

            Indonesian = id

            Portuguese = pt

            French = fr

            Malay = ms

            Dutch = n

            Japanese = ja

            Italian = it

            Romanian = ro

            Traditional Chinese = zh-Hant

            Korean = ko
          required: false
          schema:
            type: string
            example: nothing
            default: nothing
          example: nothing
        - name: ad_format
          in: query
          description: |-
            Ad style (choose one option)
            The default value "nothing" means not selecting any condition.
            Spark Ads = 1
            Non-Spark Ads = 2
          required: false
          schema:
            type: string
            example: nothing
            default: nothing
          example: nothing
        - name: like
          in: query
          description: |-
            Number of likes (optional)
            The default value "nothing" means no condition is selected.
            Top 1-20% = 1
            Top 21-40% = 2
            Top 41-60% = 3
            Top 61-80% = 4
            Top 81-100% = 5
          required: false
          schema:
            type: string
            example: nothing
            default: nothing
          example: nothing
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties: {}
                example:
                  code: 0
                  message: success
                  data:
                    materials:
                      - ad_title: หมดเก่งมาก
                        brand_name: ''
                        cost: 2
                        ctr: 0.89
                        favorite: false
                        id: '7599496668887564304'
                        industry_key: label_23132000000
                        is_search: true
                        like: 58400
                        objective_key: campaign_objective_video_view
                        tag: 2
                        video_info:
                          vid: v29044g50000d4sn397og65m159dbpqg
                          duration: 33.8
                          cover: >-
                            https://p16-sign-sg.tiktokcdn.com/tos-alisg-p-0037/oMaUBL5lEVpCYT7IcAPQ5cCd1ixAZiEBs2aIV~tplv-noop.image?dr=18692&refresh_token=754132a5&x-expires=1770134518&x-signature=Y2HoCVgbuaqkcxIQShxr1oNUYUM%3D&t=9276707c&ps=14f1eb3e&shp=9e36835a&shcp=317596d8&idc=my&VideoID=v29044g50000d4sn397og65m159dbpqg
                          video_url:
                            720p: >-
                              https://v16m-default.tiktokcdn.com/437306c551d75065fac84cd69e613e83/69821bf6/video/tos/alisg/tos-alisg-pve-0037c001/oQGT2QpiVYDaaBLEdVQ1l56FIQ7C5EExABPic/?a=0&bti=NTU4QDM1NGA%3D&ch=0&cr=0&dr=0&lr=tiktok_business&cd=0%7C0%7C0%7C0&cv=1&br=2456&bt=1228&cs=0&ds=3&ft=cApXJCz7ThWHEWo.1GZmo0P&mime_type=video_mp4&qs=0&rc=PDhoOTYzMzw6Zjk0NzhoZUBpanNnOHA5cjxxNzMzODczNUBeXzAwMDA2X2AxMi0wYGM1YSNuXzYuMmQ0MHBhLS1kMTZzcw%3D%3D&vvpl=1&l=202602031801244A1B2C464168A5C8DBB2&btag=e00088000
                          width: 576
                          height: 1024
                    pagination:
                      has_more: true
                      page: 1
                      size: 1
                      total_count: 400
                  requestId: 9aa4d8b1-8ae8-4f6b-9c4c-3756f02bb020
        '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
      deprecated: false
      security:
        - JWT Bearer: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl --request GET \
              --url 'https://api.keyapi.ai/v1/tiktok/insights/ads?search_keyword=FALSE&order_by=for_you&page=1&limit=20&period=7&region=nothing&industry=nothing&objective=nothing&ad_language=nothing&ad_format=nothing&like=nothing' \
              --header 'Authorization: Bearer <YOUR_API_KEY>'
        - lang: python
          label: Python
          source: |-
            import requests

            response = requests.get(
                'https://api.keyapi.ai/v1/tiktok/insights/ads',
                params={"search_keyword": "FALSE", "order_by": "for_you", "page": "1", "limit": "20", "period": "7", "region": "nothing", "industry": "nothing", "objective": "nothing", "ad_language": "nothing", "ad_format": "nothing", "like": "nothing"},
                headers={'Authorization': 'Bearer <YOUR_API_KEY>'}
            )
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: >-
            const params = new URLSearchParams({"search_keyword": "FALSE",
            "order_by": "for_you", "page": "1", "limit": "20", "period": "7",
            "region": "nothing", "industry": "nothing", "objective": "nothing",
            "ad_language": "nothing", "ad_format": "nothing", "like":
            "nothing"});


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

            const data = await response.json();

            console.log(data);
components:
  securitySchemes:
    JWT Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |-
        API key for authentication. Format: `sk_live_xxxxxxxxxxxxx`
        Get your API key from the [Dashboard](http://keyapi.ai/app/dashboard).

````