{
  "openapi": "3.0.1",
  "info": {
    "title": "TikTok Ads Library Scraper & Ad Monitor",
    "description": "Scrape the TikTok Ads Library by keyword, advertiser, URL, or ad ID in 33 European markets. Get advertisers, dates, landing pages, targeting, and reach by country with age and gender splits. Monitor new competitor ads, download ad videos, and export to JSON, CSV, or Excel. No login.",
    "version": "1.0",
    "x-build-id": "FWQsjRW8T7HeWX0Of"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/valev-lab~tiktok-ads-library/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-valev-lab-tiktok-ads-library",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/valev-lab~tiktok-ads-library/runs": {
      "post": {
        "operationId": "runs-sync-valev-lab-tiktok-ads-library",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/valev-lab~tiktok-ads-library/run-sync": {
      "post": {
        "operationId": "run-sync-valev-lab-tiktok-ads-library",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "searchTerms": {
            "title": "Search terms",
            "type": "array",
            "description": "Keywords, advertiser names, or pasted Ads Library URLs. Wrap a phrase in quotes for exact match. Empty searches all ads for the regions and dates.",
            "items": {
              "type": "string"
            },
            "default": [
              "nike"
            ]
          },
          "searchBy": {
            "title": "Search by",
            "enum": [
              "keyword",
              "advertiser"
            ],
            "type": "string",
            "description": "How to interpret non-URL search terms.",
            "default": "keyword"
          },
          "advertiserIds": {
            "title": "Advertiser business IDs",
            "type": "array",
            "description": "Optional adv_biz_ids. Skips name resolution when set with advertiser search.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "adIds": {
            "title": "Ad IDs or detail URLs",
            "type": "array",
            "description": "Ad IDs or library detail URLs to fetch directly. Turn on Fetch ad details to add targeting and reach.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "regions": {
            "title": "Regions",
            "type": "array",
            "description": "all or ISO country codes from the Commercial Content Library (33 markets).",
            "items": {
              "type": "string"
            },
            "default": [
              "FR"
            ]
          },
          "startDate": {
            "title": "Start date",
            "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
            "type": "string",
            "description": "YYYY-MM-DD. Earlier than ~1 year is clamped with a warning."
          },
          "endDate": {
            "title": "End date",
            "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
            "type": "string",
            "description": "YYYY-MM-DD. Empty means today."
          },
          "adStatus": {
            "title": "Ad status",
            "enum": [
              "all",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Filter by active, inactive, or all ads.",
            "default": "all"
          },
          "adFormat": {
            "title": "Ad format",
            "enum": [
              "all",
              "video",
              "image",
              "text"
            ],
            "type": "string",
            "description": "Filter by video, image, text, or all formats.",
            "default": "all"
          },
          "ages": {
            "title": "Audience age",
            "type": "array",
            "description": "TikTok buckets such as 18,24 or 55,100. Empty means all.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "gender": {
            "title": "Audience gender",
            "enum": [
              "all",
              "female",
              "male"
            ],
            "type": "string",
            "description": "Audience gender filter.",
            "default": "all"
          },
          "reach": {
            "title": "Unique reach",
            "type": "array",
            "description": "0-10K, 10K-100K, or 100K+.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "sortBy": {
            "title": "Sort by",
            "enum": [
              "last_shown_desc",
              "last_shown_asc",
              "first_shown_desc",
              "impression_desc",
              "impression_asc"
            ],
            "type": "string",
            "description": "Order of search results from the Ads Library API.",
            "default": "last_shown_desc"
          },
          "maxAds": {
            "title": "Maximum ads",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Total ads to deliver in this run. Empty-input health check uses 5.",
            "default": 5
          },
          "maxAdsPerQuery": {
            "title": "Max ads per search term × region",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Optional per-query cap. Empty uses maxAds."
          },
          "fetchDetails": {
            "title": "Fetch ad details",
            "type": "boolean",
            "description": "Adds targeting (countries, ages, genders, languages, interests) and impressions per country by age and gender. Slower: about 5 seconds per ad.",
            "default": false
          },
          "downloadMedia": {
            "title": "Download media files",
            "type": "boolean",
            "description": "Save each ad's videos and images in the run storage and link them in the results. Charged per saved file; previews are free and files over 30 MB are skipped.",
            "default": false
          },
          "countOnly": {
            "title": "Count only",
            "type": "boolean",
            "description": "Only report how many ads TikTok has for each search. No ads are saved or charged.",
            "default": false
          },
          "onlyNewAds": {
            "title": "Only new ads",
            "type": "boolean",
            "description": "Return only ads not seen in earlier runs with the same monitor name. Already seen ads are skipped and not charged. Best with a schedule.",
            "default": false
          },
          "monitorName": {
            "title": "Monitor name",
            "type": "string",
            "description": "Name for this monitor. Runs with the same name share their seen-ads list.",
            "default": "default"
          },
          "includeAdvertiserSummary": {
            "title": "Advertiser summary",
            "type": "boolean",
            "description": "Save an ADVERTISERS record with ad counts per advertiser in the run storage. Free.",
            "default": true
          },
          "outputFormat": {
            "title": "Output format",
            "enum": [
              "clean",
              "compatible"
            ],
            "type": "string",
            "description": "clean camelCase fields, or compatible Title Case keys used by other Ads Library actors.",
            "default": "compatible"
          },
          "timezone": {
            "title": "Timezone",
            "type": "string",
            "description": "Timezone label stored on the run summary. Dates remain UTC day boundaries.",
            "default": "UTC"
          },
          "maxConcurrency": {
            "title": "Max concurrency",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "Reserved. Regions are searched one after another.",
            "default": 4
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Advanced, API only. Leave empty. You can pass your own proxyUrls at your own cost; Apify Residential is not supported and runs without a proxy.",
            "default": {
              "useApifyProxy": false
            }
          },
          "debug": {
            "title": "Debug cost telemetry",
            "type": "boolean",
            "description": "Hidden operator flag. Logs COST_ESTIMATE when true.",
            "default": false
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}