{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ad Library Scraper Pro",
    "description": "Scrape Facebook Ads Library by keyword, page URL, or advertiser name. Returns full creative + CTA + linkUrl + advertiser identity + active dates. 35% cheaper than the leading alternative. No login required, country dropdown, multi-platform/media filters, resume checkpoints.",
    "version": "0.2",
    "x-build-id": "Bat4D87EeNFk7HXJZ"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/constructive_calm~facebook-ad-library-pro/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-constructive_calm-facebook-ad-library-pro",
        "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/constructive_calm~facebook-ad-library-pro/runs": {
      "post": {
        "operationId": "runs-sync-constructive_calm-facebook-ad-library-pro",
        "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/constructive_calm~facebook-ad-library-pro/run-sync": {
      "post": {
        "operationId": "run-sync-constructive_calm-facebook-ad-library-pro",
        "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": {
          "urls": {
            "title": "🔗 URLs (search or page)",
            "type": "array",
            "description": "Paste Ad Library search URLs (https://www.facebook.com/ads/library/?...) or raw Facebook page URLs (https://www.facebook.com/ZapierApp). Auto-detected. Accepts both string arrays and curious_coder-style [{url: \"...\"}] shape for migration. Leave blank if using the Keyword or Advertiser name fields below.",
            "items": {
              "type": "string"
            }
          },
          "keyword": {
            "title": "🔍 Keyword (auto-builds search URL)",
            "type": "string",
            "description": "Type a search term — we'll build the Ad Library search URL for you using the Country + Media type + Ad type filters below. Faster than hand-crafting `q=` params. Example: `nike`. Leave blank if using URLs above."
          },
          "advertiserName": {
            "title": "🏷️ Advertiser name (auto-builds search URL)",
            "type": "string",
            "description": "Search by advertiser name instead of keyword (search_type=page). Returns ads from pages matching that name. Example: `Spotify`. Leave blank if using Keyword or URLs above."
          },
          "country": {
            "title": "🌍 Country",
            "enum": [
              "ALL",
              "US",
              "GB",
              "CA",
              "AU",
              "DE",
              "FR",
              "IT",
              "ES",
              "NL",
              "SE",
              "NO",
              "DK",
              "FI",
              "IE",
              "BE",
              "AT",
              "CH",
              "PL",
              "PT",
              "GR",
              "RO",
              "CZ",
              "HU",
              "BR",
              "MX",
              "AR",
              "CL",
              "CO",
              "IN",
              "ID",
              "PH",
              "TH",
              "VN",
              "MY",
              "SG",
              "JP",
              "KR",
              "TW",
              "HK",
              "AE",
              "SA",
              "EG",
              "IL",
              "TR",
              "ZA",
              "NG",
              "KE",
              "GH",
              "NZ",
              "RU",
              "UA"
            ],
            "type": "string",
            "description": "Two-letter ISO country code. Only used when Keyword or Advertiser name is set, OR to override the country from a pasted URL. If your country isn't listed, use Custom country code below.",
            "default": "ALL"
          },
          "customCountryCode": {
            "title": "Custom country code (optional)",
            "type": "string",
            "description": "Overrides the dropdown above. 2-letter ISO 3166-1 alpha-2 code (e.g., `BD` for Bangladesh, `PK` for Pakistan). Leave blank to use the dropdown."
          },
          "mediaType": {
            "title": "🖼️ Media type",
            "enum": [
              "all",
              "image",
              "video",
              "meme",
              "image_and_meme",
              "none"
            ],
            "type": "string",
            "description": "Filter by creative format. Maps to the Ad Library `media_type=` URL parameter.",
            "default": "all"
          },
          "adType": {
            "title": "📂 Ad category",
            "enum": [
              "all",
              "political_and_issue_ads",
              "housing_ads",
              "employment_ads",
              "credit_ads",
              "financial_products_and_services_ads"
            ],
            "type": "string",
            "description": "Filter by ad category. Political & social ads include extra fields (spend range, impressions range, demographic reach).",
            "default": "all"
          },
          "platforms": {
            "title": "📱 Publisher platforms",
            "type": "array",
            "description": "Filter ads by the platforms they run on. One per line: FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS, WHATSAPP. Leave blank for all.",
            "items": {
              "type": "string"
            }
          },
          "period": {
            "title": "🗓️ Date range",
            "enum": [
              "",
              "last24h",
              "last7d",
              "last14d",
              "last30d"
            ],
            "type": "string",
            "description": "Limit to ads ACTIVE in this window. Note: many ads run for months/years, so the `startDate` field in the output may show a date older than the window — that's the ad's original run-start date, not when it was indexed. For 'newly launched ads only', also set sortBy=most_recent.",
            "default": ""
          },
          "activeStatus": {
            "title": "Active status",
            "enum": [
              "all",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Filter by whether the ad is still running.",
            "default": "all"
          },
          "sortBy": {
            "title": "Sort by",
            "enum": [
              "impressions_desc",
              "most_recent"
            ],
            "type": "string",
            "description": "Result ordering. Defaults to highest-impressions-first (matches the Ad Library UI default).",
            "default": "impressions_desc"
          },
          "scrapeAdDetails": {
            "title": "💎 Scrape ad details (EU reach + AAA)",
            "type": "boolean",
            "description": "Fire a second call per ad to fetch EU demographic reach (age × gender × country breakdown) and AAA targeting metadata. Per Meta's policy, full reach is only exposed for political/social-issue ads — commercial ads usually return empty. We only charge $0.25/1K when non-empty data comes back. Off by default.",
            "default": false
          },
          "resolveAdvertiser": {
            "title": "🏢 Resolve advertiser About page",
            "type": "boolean",
            "description": "Fetch each advertiser's public About page (verified status, categories, profile pic) — ONCE per page, regardless of how many ads they have. Costs $1 per 1,000 unique advertisers — much cheaper than competitors who refetch per ad.",
            "default": false
          },
          "limitPerSource": {
            "title": "#️⃣ Limit per input URL",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Cap the number of ads scraped per input URL / keyword. Leave blank to scrape all available ads. Actual count may exceed by up to 30 (one extra paginated batch)."
          },
          "count": {
            "title": "#️⃣ Total ads cap (across all sources)",
            "minimum": 1,
            "maximum": 1000000,
            "type": "integer",
            "description": "Hard ceiling on total ads emitted by this run. Overrides limitPerSource when reached. Leave blank for unlimited."
          },
          "enableCheckpoint": {
            "title": "💾 Enable resume checkpoint",
            "type": "boolean",
            "description": "Save progress every batch to the key-value store. If the run crashes or is restarted within 6 hours with the same input, resume from where it stopped instead of paying for already-scraped ads.",
            "default": true
          },
          "maxConcurrency": {
            "title": "Concurrent fetches",
            "minimum": 1,
            "maximum": 5,
            "type": "integer",
            "description": "Parallel paginations across input URLs. Facebook is sensitive to per-IP load — keep at 2-3 unless using high-rotation residential proxy.",
            "default": 2
          },
          "runTag": {
            "title": "🏷️ Run tag",
            "type": "string",
            "description": "Optional label echoed into every output row's `runTag` column. Useful for joining datasets from scheduled runs."
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Residential proxy strongly recommended — datacenter IPs get CAPTCHA'd within tens of requests. Country override here will change the proxy egress (different from the ad-search country).",
            "default": {
              "useApifyProxy": true,
              "apifyProxyGroups": [
                "RESIDENTIAL"
              ]
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}