{
  "openapi": "3.0.1",
  "info": {
    "title": "Meta Ads Library Scraper",
    "description": "Scrapes the public Meta (Facebook) Ads Library by keyword, advertiser page, or Ad Library URL. Uses curl_cffi Chrome TLS impersonation and GraphQL pagination. No Facebook login required.",
    "version": "0.1",
    "x-build-id": "WEqmL8ICAGthUJPqf"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/competent_clarinet~facebook-ads-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-competent_clarinet-facebook-ads-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/competent_clarinet~facebook-ads-scraper/runs": {
      "post": {
        "operationId": "runs-sync-competent_clarinet-facebook-ads-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/competent_clarinet~facebook-ads-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-competent_clarinet-facebook-ads-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": {
          "queries": {
            "title": "Queries",
            "type": "array",
            "description": "Search queries for KEYWORD_UNORDERED search. Each query runs as its own search. Max 255 characters per query.",
            "items": {
              "type": "string"
            }
          },
          "phrases": {
            "title": "Exact phrases",
            "type": "array",
            "description": "Exact phrase searches (KEYWORD_EXACT_PHRASE). Each entry is a list of up to 5 words (max 255 chars each) joined into one phrase."
          },
          "pageUrls": {
            "title": "Advertiser page URLs",
            "type": "array",
            "description": "Facebook page URLs (e.g. https://www.facebook.com/nike). Vanity URLs are resolved to a page ID before scraping.",
            "items": {
              "type": "string"
            }
          },
          "pageIds": {
            "title": "Advertiser page IDs",
            "type": "array",
            "description": "Numeric Facebook page IDs. Each ID runs a PAGE search without URL resolution.",
            "items": {
              "type": "string"
            }
          },
          "filterPageIds": {
            "title": "Filter by page IDs",
            "maxItems": 10,
            "type": "array",
            "description": "Numeric Facebook page IDs used to narrow query and phrase searches (maps to page_ids[0], page_ids[1], ... in the Ad Library URL and pageIDs in GraphQL). At most 10 IDs. Ignored for pageUrls, pageIds, and startUrls.",
            "items": {
              "type": "string"
            }
          },
          "sortByMode": {
            "title": "Sort by",
            "enum": [
              "SORT_BY_TOTAL_IMPRESSIONS",
              "SORT_BY_RELEVANCY_MONTHLY_GROUPED"
            ],
            "type": "string",
            "description": "How Meta orders search results for queries and phrases (sort_data[mode] in the built Ad Library URL). Ignored for startUrls.",
            "default": "SORT_BY_TOTAL_IMPRESSIONS"
          },
          "startUrls": {
            "title": "Ad Library URLs",
            "type": "array",
            "description": "Full Meta Ad Library URLs (https://www.facebook.com/ads/library/?...). Each URL is fetched as-is; pagination uses parameters decoded from the URL. Actor input filters (country, filterPageIds, sortByMode, etc.) do not apply to startUrls.",
            "items": {
              "type": "string"
            }
          },
          "adLibraryIds": {
            "title": "Ad library IDs",
            "type": "array",
            "description": "Numeric Meta ad library IDs (ad archive IDs). Each ID fetches one ad directly — no search pagination.",
            "items": {
              "type": "string"
            }
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code (e.g. US, IN, GB), or ALL for worldwide search. Applies to queries, phrases, pageUrls, and pageIds — not startUrls.",
            "default": "ALL"
          },
          "adActiveStatus": {
            "title": "Ad status",
            "enum": [
              "ALL",
              "ACTIVE",
              "INACTIVE"
            ],
            "type": "string",
            "description": "Return only active ads, only inactive ads, or both.",
            "default": "ACTIVE"
          },
          "adType": {
            "title": "Ad category",
            "enum": [
              "ALL",
              "POLITICAL_AND_ISSUE_ADS",
              "HOUSING_ADS",
              "EMPLOYMENT_ADS",
              "CREDIT_ADS"
            ],
            "type": "string",
            "description": "Meta transparency category filter.",
            "default": "ALL"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "ALL",
              "IMAGE",
              "IMAGE_AND_MEME",
              "VIDEO",
              "MEME",
              "NONE"
            ],
            "type": "string",
            "description": "Restrict results by creative format.",
            "default": "ALL"
          },
          "publisherPlatforms": {
            "title": "Publisher platforms",
            "type": "array",
            "description": "Only include ads that ran on these Meta surfaces. Leave empty to search all platforms — no publisher_platforms query params are added to the Ad Library URL.",
            "items": {
              "type": "string",
              "enum": [
                "FACEBOOK",
                "INSTAGRAM",
                "AUDIENCE_NETWORK",
                "MESSENGER",
                "WHATSAPP",
                "THREADS"
              ],
              "enumTitles": [
                "Facebook",
                "Instagram",
                "Audience Network",
                "Messenger",
                "WhatsApp",
                "Threads"
              ]
            },
            "default": []
          },
          "languages": {
            "title": "Ad languages",
            "type": "array",
            "description": "ISO 639-1 language codes for ad creative (e.g. en, fr, hi). Leave empty for any language.",
            "items": {
              "type": "string"
            }
          },
          "dateFrom": {
            "title": "Earliest start date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Only include ads that first ran on or after this date (YYYY-MM-DD)."
          },
          "dateTo": {
            "title": "Latest start date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Only include ads that first ran on or before this date (YYYY-MM-DD)."
          },
          "maxResultsPerSource": {
            "title": "Maximum results per source",
            "minimum": 0,
            "type": "integer",
            "description": "Cap on ads collected per search source (query, phrase, page, URL, etc.). Set to 0 for unlimited pagination for each source.",
            "default": 100
          },
          "maxConcurrency": {
            "title": "Max concurrency",
            "minimum": 1,
            "maximum": 10,
            "type": "integer",
            "description": "Maximum number of search sources processed in parallel.",
            "default": 3
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Apify Proxy or custom proxies. Residential proxy is strongly recommended — Meta blocks most datacenter IPs."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}