{
  "openapi": "3.0.1",
  "info": {
    "title": "TikTok Ads Library Scraper - Ad Spy",
    "description": "Scrape TikTok Commercial Content Library ads by keyword, advertiser, business ID, country, date range, or ad URL. Extract creatives, video URLs, targeting, reach buckets, sponsors, and advertiser metadata.",
    "version": "1.0",
    "x-build-id": "jL5q8ggEUCRMCJwjb"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/elliotpadfield~tiktok-ads-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-elliotpadfield-tiktok-ads-library-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/elliotpadfield~tiktok-ads-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-elliotpadfield-tiktok-ads-library-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/elliotpadfield~tiktok-ads-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-elliotpadfield-tiktok-ads-library-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": {
          "keywords": {
            "title": "Keywords",
            "uniqueItems": true,
            "type": "array",
            "description": "Search ad text and advertiser content by one or more words or phrases, such as competitor names, categories, products, or hooks.",
            "items": {
              "type": "string"
            },
            "default": [
              "nike"
            ]
          },
          "queries": {
            "title": "Quick Keyword Queries",
            "uniqueItems": true,
            "type": "array",
            "description": "Alias for Keywords. Useful when triggering the Actor from API clients that use a generic queries field.",
            "items": {
              "type": "string"
            }
          },
          "advertiserNames": {
            "title": "Advertiser Names",
            "uniqueItems": true,
            "type": "array",
            "description": "Search by advertiser name as shown in TikTok Commercial Content Library.",
            "items": {
              "type": "string"
            }
          },
          "advertiserBusinessIds": {
            "title": "Advertiser Business IDs",
            "uniqueItems": true,
            "type": "array",
            "description": "Search exact TikTok advertiser business IDs, such as IDs found in detail-page advertiser metadata.",
            "items": {
              "type": "string"
            }
          },
          "adUrls": {
            "title": "Direct Ad URLs or IDs",
            "uniqueItems": true,
            "type": "array",
            "description": "Paste TikTok Ad Library detail URLs or numeric ad IDs to enrich specific ads directly.",
            "items": {
              "type": "string"
            }
          },
          "detailUrls": {
            "title": "Direct Detail URLs",
            "uniqueItems": true,
            "type": "array",
            "description": "Alias for Direct Ad URLs or IDs. Kept for integration compatibility.",
            "items": {
              "type": "string"
            }
          },
          "countries": {
            "title": "Countries",
            "uniqueItems": true,
            "type": "array",
            "description": "TikTok country codes to search. TikTok Commercial Content Library coverage is strongest for EEA, Switzerland, and the United Kingdom. Defaults to GB.",
            "items": {
              "type": "string"
            },
            "default": [
              "GB"
            ]
          },
          "dateFrom": {
            "title": "Start Date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Optional start date for TikTok's last-shown date filter. Use YYYY-MM-DD."
          },
          "dateTo": {
            "title": "End Date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Optional end date for TikTok's last-shown date filter. Use YYYY-MM-DD."
          },
          "queryType": {
            "title": "Keyword Query Type",
            "enum": [
              "keyword",
              "advertiserName",
              "all"
            ],
            "type": "string",
            "description": "How TikTok should interpret keyword searches. Keyword is usually best for discovery; advertiser name is best for exact brand searches.",
            "default": "keyword"
          },
          "adType": {
            "title": "Ad Type",
            "enum": [
              "1",
              "2",
              "3",
              "4"
            ],
            "type": "string",
            "description": "TikTok ad type code. Use 1 for all ads, 2 for employment, 3 for housing, or 4 for credit if supported in the selected region.",
            "default": "1"
          },
          "sortOrder": {
            "title": "Sort Order",
            "enum": [
              "last_shown_date,desc",
              "last_shown_date,asc",
              "first_shown_date,desc",
              "first_shown_date,asc",
              "audience_size,desc",
              "audience_size,asc"
            ],
            "type": "string",
            "description": "Sort order passed to TikTok search.",
            "default": "last_shown_date,desc"
          },
          "quickSearch": {
            "title": "Quick Search",
            "type": "boolean",
            "description": "Skip detail-page enrichment for faster preview runs. Disable this when using region targeting filters or when you need sponsor, registry, and targeting metadata.",
            "default": false
          },
          "adFormats": {
            "title": "Ad Formats",
            "uniqueItems": true,
            "type": "array",
            "description": "Optional post-filter for detected creative format.",
            "items": {
              "type": "string"
            }
          },
          "regionFilter": {
            "title": "Target Region Filter",
            "uniqueItems": true,
            "type": "array",
            "description": "Optional post-filter for target regions found on detail pages, such as GB, DE, FR, NL, ES, IT, or CH. Requires detail enrichment.",
            "items": {
              "type": "string"
            }
          },
          "minAudienceLower": {
            "title": "Minimum Audience Bucket",
            "minimum": 0,
            "type": "integer",
            "description": "Optional post-filter using the lower bound of TikTok's estimated audience bucket. Example: 100000 keeps ads with buckets starting at 100K or higher."
          },
          "maxAudienceLower": {
            "title": "Maximum Audience Bucket",
            "minimum": 0,
            "type": "integer",
            "description": "Optional post-filter using the lower bound of TikTok's estimated audience bucket. Example: 1000000 keeps ads with buckets starting at 1M or lower."
          },
          "maxAds": {
            "title": "Maximum Ads",
            "minimum": 1,
            "maximum": 5000,
            "type": "integer",
            "description": "Maximum number of unique ads to save across all search sources and direct ad URLs.",
            "default": 100
          },
          "maxPages": {
            "title": "Maximum Search Pages",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Maximum pagination pages to fetch per search source. TikTok search pages normally contain 12 ads.",
            "default": 5
          },
          "includeDetails": {
            "title": "Include Full Ad Details",
            "type": "boolean",
            "description": "Fetch each TikTok ad detail page to get advertiser business ID, registry location, sponsor, targeting, and richer media metadata.",
            "default": true
          },
          "maxConcurrency": {
            "title": "Maximum Concurrency",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "Number of ad detail pages to fetch in parallel.",
            "default": 5
          },
          "requestDelayMs": {
            "title": "Retry Delay",
            "minimum": 0,
            "maximum": 10000,
            "type": "integer",
            "description": "Base delay in milliseconds between retry attempts after transient failures.",
            "default": 500
          },
          "maxRetries": {
            "title": "Maximum Retries",
            "minimum": 0,
            "maximum": 8,
            "type": "integer",
            "description": "Number of retries for transient HTTP, timeout, or proxy failures.",
            "default": 3
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}