{
  "openapi": "3.0.1",
  "info": {
    "title": "TikTok Ads Library Records Scraper",
    "description": "Search TikTok Ads Library by advertiser or keyword. Export ad records with advertiser, video and image links, first and last shown dates, and unique-user ranges for ad compliance and competitor monitoring.",
    "version": "0.1",
    "x-build-id": "MTt1cdWYyMx5KX2iD"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/automation-lab~tiktok-ads-library-records-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-automation-lab-tiktok-ads-library-records-scraper",
        "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/automation-lab~tiktok-ads-library-records-scraper/runs": {
      "post": {
        "operationId": "runs-sync-automation-lab-tiktok-ads-library-records-scraper",
        "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/automation-lab~tiktok-ads-library-records-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-automation-lab-tiktok-ads-library-records-scraper",
        "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": "Advertiser names or keywords to search in TikTok's Ads Library, one per line. Each term is a separate search with its own Max results limit. An ad found by more than one search is saved once, under the first search that found it. For one specific advertiser, use a Library URL instead.",
            "items": {
              "type": "string"
            }
          },
          "matchType": {
            "title": "Search term matching",
            "enum": [
              "broad",
              "exact"
            ],
            "type": "string",
            "description": "How Search terms are matched. Broad uses TikTok's normal matching, which can also return related advertisers. Exact sends the term as a quoted phrase, matching TikTok's own quoted search. Does not apply to Library URLs.",
            "default": "broad"
          },
          "startUrls": {
            "title": "Library URLs",
            "type": "array",
            "description": "Search pages copied from library.tiktok.com/ads, for example the See all ads link of an advertiser. Filters inside an address replace the filters below for that search; anything the address leaves out uses the filters below. Single-ad pages are not supported.",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "regions": {
            "title": "Regions",
            "uniqueItems": true,
            "type": "array",
            "description": "Where the ads were shown. TikTok publishes this library for the listed regions only; other countries such as the United States are not available. Choosing several regions runs one search across all of them.",
            "items": {
              "type": "string",
              "enum": [
                "all",
                "AT",
                "BE",
                "BG",
                "BR",
                "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"
              ],
              "enumTitles": [
                "All supported regions",
                "Austria",
                "Belgium",
                "Bulgaria",
                "Brazil",
                "Switzerland",
                "Cyprus",
                "Czech Republic",
                "Germany",
                "Denmark",
                "Estonia",
                "Spain",
                "Finland",
                "France",
                "United Kingdom",
                "Greece",
                "Croatia",
                "Hungary",
                "Ireland",
                "Iceland",
                "Italy",
                "Liechtenstein",
                "Lithuania",
                "Luxembourg",
                "Latvia",
                "Malta",
                "Netherlands",
                "Norway",
                "Poland",
                "Portugal",
                "Romania",
                "Sweden",
                "Slovenia",
                "Slovakia",
                "Turkey"
              ]
            },
            "default": [
              "all"
            ]
          },
          "dateFrom": {
            "title": "Shown from",
            "type": "string",
            "description": "Keep ads shown on or after this date (UTC). Leave empty for the 365 days before Shown until."
          },
          "dateTo": {
            "title": "Shown until",
            "type": "string",
            "description": "Keep ads shown on or before this date (UTC, the whole day counts). Leave empty for today."
          },
          "adStatus": {
            "title": "Ad status",
            "enum": [
              "all",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Filter by whether TikTok lists the ad as active or inactive.",
            "default": "all"
          },
          "adType": {
            "title": "Ad format",
            "enum": [
              "all",
              "video",
              "image"
            ],
            "type": "string",
            "description": "Filter by the ad's creative format.",
            "default": "all"
          },
          "gender": {
            "title": "Target gender",
            "enum": [
              "all",
              "female",
              "male"
            ],
            "type": "string",
            "description": "Keep ads TikTok reports as targeted at this gender.",
            "default": "all"
          },
          "ages": {
            "title": "Target age ranges",
            "uniqueItems": true,
            "type": "array",
            "description": "Keep ads targeted at any of these age ranges. Leave empty for all ages.",
            "items": {
              "type": "string",
              "enum": [
                "13,17",
                "18,24",
                "25,34",
                "35,44",
                "45,54",
                "55,100"
              ],
              "enumTitles": [
                "13-17",
                "18-24",
                "25-34",
                "35-44",
                "45-54",
                "55+"
              ]
            }
          },
          "reach": {
            "title": "Unique users seen",
            "uniqueItems": true,
            "type": "array",
            "description": "Keep ads whose unique-viewer range falls in any of these buckets. Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "0-10K",
                "10K-100K",
                "100K+"
              ],
              "enumTitles": [
                "Below 10K",
                "10K to 100K",
                "Above 100K"
              ]
            }
          },
          "sort": {
            "title": "Sort by",
            "enum": [
              "lastShownNewest",
              "lastShownOldest",
              "publishedNewest",
              "publishedOldest",
              "mostUniqueUsers",
              "fewestUniqueUsers"
            ],
            "type": "string",
            "description": "Order of results, which decides which ads you get when a search has more matches than Max results. Works with an exact phrase or an advertiser link. On a broad search TikTok ignores it and returns ads by relevance.",
            "default": "lastShownNewest"
          },
          "maxResults": {
            "title": "Max results per search",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Most ads saved from each search term, advertiser or search URL. You are charged per ad saved.",
            "default": 50
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}