{
  "openapi": "3.0.1",
  "info": {
    "title": "TikTok Ad Library Scraper - Reliable",
    "description": "Scrape the TikTok Ad Library (EU/EEA, UK, CH, TR) by advertiser, keyword, country, date, status, format, reach, age and gender. Fast cards or full details: landing page, CTA, objective, paid by, TikTok account, impressions by country/age/gender, targeting.",
    "version": "0.1",
    "x-build-id": "dKEdOaufHYeygiPjg"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/atlasdata~tiktok-ad-library-scraper-reliable/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-atlasdata-tiktok-ad-library-scraper-reliable",
        "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/atlasdata~tiktok-ad-library-scraper-reliable/runs": {
      "post": {
        "operationId": "runs-sync-atlasdata-tiktok-ad-library-scraper-reliable",
        "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/atlasdata~tiktok-ad-library-scraper-reliable/run-sync": {
      "post": {
        "operationId": "run-sync-atlasdata-tiktok-ad-library-scraper-reliable",
        "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 (advertiser name or keyword)",
            "type": "array",
            "description": "Each entry is one search, exactly like the search box on library.tiktok.com: it matches advertiser names and ad text. Wrap a term in double quotes (\"black friday\") for an exact-phrase search.",
            "items": {
              "type": "string"
            }
          },
          "adLibraryUrls": {
            "title": "TikTok Ad Library URLs",
            "type": "array",
            "description": "Optional. Paste search URLs (https://library.tiktok.com/ads?region=...&adv_name=...) - all their filters are kept - or single ad URLs (https://library.tiktok.com/ads/detail/?ad_id=...).",
            "items": {
              "type": "string"
            }
          },
          "adIds": {
            "title": "Ad IDs",
            "type": "array",
            "description": "Optional. Numeric TikTok ad IDs to look up directly (full details for each).",
            "items": {
              "type": "string"
            }
          },
          "countries": {
            "title": "Countries where the ad was shown",
            "type": "array",
            "description": "ISO codes. The TikTok Ad Library only covers the EU/EEA, Switzerland, the UK and Turkey: AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HR HU IE IS IT LI LT LU LV MT NL NO PL PT RO SE SI SK TR. Leave empty for all of them. Other codes are ignored and reported in OUTPUT.inputErrors.",
            "items": {
              "type": "string"
            }
          },
          "dateRange": {
            "title": "Date range (ad shown)",
            "enum": [
              "last-7-days",
              "last-30-days",
              "last-90-days",
              "last-12-months",
              "all",
              "custom"
            ],
            "type": "string",
            "description": "Only ads shown in this period. Not applied to pasted search URLs, which keep their own dates.",
            "default": "last-12-months"
          },
          "startDate": {
            "title": "Start date (custom range)",
            "type": "string",
            "description": "YYYY-MM-DD. Used only when Date range = Custom."
          },
          "endDate": {
            "title": "End date (custom range)",
            "type": "string",
            "description": "YYYY-MM-DD. Defaults to today."
          },
          "adStatus": {
            "title": "Ad status",
            "enum": [
              "all",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Active = still running.",
            "default": "all"
          },
          "mediaType": {
            "title": "Ad format",
            "enum": [
              "all",
              "video",
              "image",
              "text"
            ],
            "type": "string",
            "description": "Filter by creative format.",
            "default": "all"
          },
          "reach": {
            "title": "Unique reach",
            "type": "array",
            "description": "Optional. Only ads with this estimated unique-user reach. Empty = any.",
            "items": {
              "type": "string",
              "enum": [
                "under-10k",
                "10k-100k",
                "over-100k"
              ],
              "enumTitles": [
                "Under 10K",
                "10K - 100K",
                "Over 100K"
              ]
            }
          },
          "ages": {
            "title": "Targeted ages",
            "type": "array",
            "description": "Optional. Only ads targeting these age groups. Empty = any.",
            "items": {
              "type": "string",
              "enum": [
                "13-17",
                "18-24",
                "25-34",
                "35-44",
                "45-54",
                "55+"
              ]
            }
          },
          "gender": {
            "title": "Targeted gender",
            "enum": [
              "all",
              "female",
              "male"
            ],
            "type": "string",
            "description": "Only ads targeting this gender.",
            "default": "all"
          },
          "sortBy": {
            "title": "Sort by",
            "enum": [
              "last-shown-desc",
              "last-shown-asc",
              "published-desc",
              "published-asc",
              "reach-desc",
              "reach-asc"
            ],
            "type": "string",
            "description": "TikTok's sort order. For keyword searches TikTok mixes in relevance.",
            "default": "last-shown-desc"
          },
          "maxAdsPerSearch": {
            "title": "Max ads per search",
            "minimum": 1,
            "maximum": 5000,
            "type": "integer",
            "description": "Stop each search term / URL after this many unique ads. TikTok serves 12 ads per page and shows at most about 5,000 per search.",
            "default": 50
          },
          "includeDetails": {
            "title": "Include ad details",
            "type": "boolean",
            "description": "Off (default) = fast card-only scrape: a few hundred ads per minute. On = also open each ad's detail record: landing page URL, call to action, objective, advertiser ID and country, \"paid by\", TikTok account (username, followers, verified), impressions per country with age x gender split, and targeting (countries, regions, ages, genders, audience size, interests, languages, devices). TikTok allows only one detail lookup per page load, so details run at roughly 25-35 ads per minute and are billed as a separate event.",
            "default": false
          },
          "maxConcurrency": {
            "title": "Max concurrency",
            "minimum": 1,
            "maximum": 8,
            "type": "integer",
            "description": "Parallel browser tabs (search terms and detail pages are spread over them). 3 fits the default 2 GB memory; for large detail runs use 4 GB memory and 4 tabs. Higher values from one IP can make TikTok block the IP (the Actor then switches to Apify Proxy automatically).",
            "default": 3
          },
          "maxRetries": {
            "title": "Max retries per request",
            "minimum": 0,
            "maximum": 15,
            "type": "integer",
            "description": "Retries for each search page or detail record (with page reloads and, after repeated failures, a fresh browser session).",
            "default": 6
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Not needed - the TikTok Ad Library is public. Without a proxy the Actor uses the server's own IP (fastest) and switches to Apify datacenter proxy sessions automatically if TikTok starts blocking detail pages. Set a proxy here only if you want every request to go through it.",
            "default": {
              "useApifyProxy": 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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}