{
  "openapi": "3.0.1",
  "info": {
    "title": "TikTok Ads Library Scraper",
    "description": "Search the TikTok Ads Library by keyword, advertiser, country, ad ID, or library link. Get ad captions, video and image links, dates, advertiser, payer, targeting, and reach. Or count matching ads in EU, EEA, Swiss, UK, and Turkish markets.",
    "version": "0.0",
    "x-build-id": "iyaQtZMQWaG8RfPa2"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/maximedupre~tiktok-ads-library/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-maximedupre-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/maximedupre~tiktok-ads-library/runs": {
      "post": {
        "operationId": "runs-sync-maximedupre-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/maximedupre~tiktok-ads-library/run-sync": {
      "post": {
        "operationId": "run-sync-maximedupre-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",
        "required": [
          "resultType"
        ],
        "properties": {
          "countries": {
            "title": "Countries",
            "type": "array",
            "description": "Enter one or more country names as shown in TikTok's library country menu. Supported markets are in the EU, EEA, Switzerland, United Kingdom, and Türkiye. Invalid country choices are rejected. Required for country browsing and searches without a country in the library URL. The same countries apply to all search values.",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "maxItems": {
            "title": "Maximum results",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many saved rows across the whole run, or earlier if no more results are available. Applies to Ads and Ad counts. Leave empty or use 0 for all available rows. For Ad counts, this limits count rows, not the number of ads each count describes."
          },
          "resultType": {
            "title": "Result type",
            "enum": [
              "ads",
              "adCounts"
            ],
            "type": "string",
            "description": "Ads returns paid-ad records and their published data and available media files. Ad counts returns TikTok's matching-ad totals without collecting creatives, and marks totals that TikTok caps."
          },
          "adIds": {
            "title": "Ad IDs",
            "type": "array",
            "description": "For Ads with Find ads by set to Ad IDs. Enter one TikTok Ads Library ad ID per entry. Get the ID from the ad's library detail link. Search filters do not apply to direct ad IDs.",
            "items": {
              "type": "string",
              "pattern": "^[0-9]+$"
            }
          },
          "adSortBy": {
            "title": "Order ads by",
            "enum": [
              "lastShown",
              "reach"
            ],
            "type": "string",
            "description": "Order Ads search results by this value. Leave empty to keep the library URL's order field, or last shown date when none is set. Does not change direct ad ID or ad-detail URL lookups."
          },
          "findAdsBy": {
            "title": "Find ads by",
            "enum": [
              "advertiser",
              "keyword",
              "adId",
              "libraryUrl",
              "country"
            ],
            "type": "string",
            "description": "For Ads and Ad counts. Fill the matching list, or choose Country to browse without a search term. Ad IDs work only with Ads. Library URL accepts search URLs for either result type and ad-detail URLs only for Ads. Other inactive search lists are ignored.",
            "default": "advertiser"
          },
          "advertiserNames": {
            "title": "Advertiser names",
            "type": "array",
            "description": "Required for Advertiser name with Ads or Ad counts. Copy one full advertiser label from TikTok Ads Library's advertiser suggestions per entry, such as OpenAI, Inc. Keep all spaces and punctuation in each label. Other full labels are allowed. Each label must match one advertiser choice; missing or unclear matches are rejected without guessing or switching to Keyword. This search finds ads from the selected advertisers only. For free-text searches across advertiser names and ad text, choose Keyword. All entries use the same filters.",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "keywords": {
            "title": "Keywords",
            "type": "array",
            "description": "Required for Keyword with Ads or Ad counts. Enter one search word or phrase per entry. TikTok searches advertiser names and ad text together, so results may include other advertisers whose ads mention the phrase. Each entry is one value, including any spaces or punctuation. All entries use the same filters.",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "libraryUrls": {
            "title": "TikTok Ads Library URLs",
            "type": "array",
            "description": "Required for Library URL with Ads or Ad counts. Add full TikTok Ads Library search URLs, or ad-detail URLs for Ads. URLs must share the same search filters; separate search setups need separate runs. URL filters are kept. Leave matching form filters empty or set them to the same values. Conflicting values are invalid. Direct ad-detail links do not use search filters.",
            "items": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL",
                  "description": "Full TikTok Ads Library search or ad-detail URL.",
                  "pattern": "^https://library\\.tiktok\\.com/.*$"
                }
              },
              "required": [
                "url"
              ]
            }
          },
          "phraseMatch": {
            "title": "Search matching",
            "enum": [
              "broad",
              "phrase"
            ],
            "type": "string",
            "description": "For Advertiser name and Keyword searches with Ads or Ad counts. Whole phrase keeps the words together. Broader TikTok matching uses TikTok's broader search. Leave empty to use TikTok's setting, or the setting in a library search URL."
          },
          "lastShownFrom": {
            "title": "Last shown on or after",
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
            "type": "string",
            "description": "For Ads and Ad counts searches. Keep ads last shown on or after this date. Use YYYY-MM-DD. Leave empty for no start date."
          },
          "lastShownTo": {
            "title": "Last shown on or before",
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
            "type": "string",
            "description": "For Ads and Ad counts searches. Keep ads last shown on or before this date. Use YYYY-MM-DD. Leave empty for no end date."
          },
          "sortOrder": {
            "title": "Sort order",
            "enum": [
              "descending",
              "ascending"
            ],
            "type": "string",
            "description": "For Ads searches. Descending puts newest dates or largest values first. Ascending puts oldest dates or smallest values first. Leave empty to keep the library URL's direction, or descending when none is set. Does not apply to Ad counts or direct ad lookups."
          },
          "timeZone": {
            "title": "Time zone",
            "type": "string",
            "description": "Time zone for date filters on Ads and Ad counts. Enter an IANA time zone such as Europe/Paris or UTC. Leave empty to use the library search URL's time zone, or UTC when no time zone is in the URL."
          },
          "deliveryStatus": {
            "title": "Delivery status",
            "enum": [
              "all",
              "running",
              "stopped"
            ],
            "type": "string",
            "description": "For Ads and Ad counts searches. Choose TikTok's delivery-status category. Leave empty to keep the library URL's status, or all ads when no status is in the URL."
          },
          "creativeFormats": {
            "title": "Creative formats",
            "type": "array",
            "description": "For Ads searches, choose one or more formats. For Ad counts, choose at most one; multiple formats are invalid because TikTok does not report a combined count. All ad types includes every format and must be selected on its own. Leave empty to use the library URL's format, or All ad types when none is set.",
            "items": {
              "type": "string",
              "enum": [
                "all",
                "video",
                "image",
                "text"
              ],
              "enumTitles": [
                "All ad types",
                "Video",
                "Image",
                "Text"
              ]
            }
          },
          "audienceAges": {
            "title": "Audience age groups",
            "type": "array",
            "description": "For Ads and Ad counts searches. Copy exact age-group labels from TikTok Ads Library's audience filter, one per entry. Availability can vary by country. Leave empty for all age groups, or those in the library URL.",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "audienceGenders": {
            "title": "Audience genders",
            "type": "array",
            "description": "For Ads searches, choose Female, Male, or both. For Ad counts, choose at most one; multiple genders are invalid because TikTok does not report a combined count. All genders is a separate TikTok choice, not the same as Female and Male together. Select it on its own. Leave empty to use the library URL's gender, or All genders when none is set.",
            "items": {
              "type": "string",
              "enum": [
                "All genders",
                "Female",
                "Male"
              ],
              "enumTitles": [
                "All genders",
                "Female",
                "Male"
              ]
            }
          },
          "reachBands": {
            "title": "Audience reach bands",
            "type": "array",
            "description": "For Ads and Ad counts searches. Copy exact reach-band labels from TikTok Ads Library, one per entry. These are ranges, not exact audience counts. Leave empty for all reach bands, or those in the library URL.",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}