{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ads Library Scraper",
    "description": "Meta Ad Library scraper: export the ads of any Facebook page, keyword or Ad Library URL (filters kept) without a Facebook account. Ad copy, creatives, CTA, links, platforms, start and end dates, and optionally the products behind each ad. Exact limit, pay per ad.",
    "version": "1.0",
    "x-build-id": "zt4DLex9fUedLjJ2G"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/badr_xba~facebook-ads-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-badr_xba-facebook-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/badr_xba~facebook-ads-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-badr_xba-facebook-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/badr_xba~facebook-ads-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-badr_xba-facebook-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": {
          "startUrls": {
            "title": "🔗 Meta Ad Library URL or Facebook Page URL",
            "type": "array",
            "description": "One per line. Accepted: a Facebook Page URL (https://www.facebook.com/SHEINOFFICIAL, m.facebook.com/nike, facebook.com/profile.php?id=100064…), an advertiser or search URL from the Meta Ad Library (set your keyword, country, platforms, language and media filters on facebook.com/ads/library, then copy the URL), or a single ad URL (https://www.facebook.com/ads/library/?id=…). Duplicates and extra spaces are removed automatically; a URL that is not Facebook is skipped and listed in FAILED_INPUTS (not billed).",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "searchQueries": {
            "title": "🔎 Or search keywords / page names",
            "type": "array",
            "description": "Optional. Keywords searched in the text of the ads, in the country below (ALL = every country), e.g. running shoes or black friday. Start with @ to get a page's ads instead: @nike. Each keyword uses the same results limit.",
            "items": {
              "type": "string"
            }
          },
          "resultsLimit": {
            "title": "💯 Results limit per URL",
            "minimum": 1,
            "type": "integer",
            "description": "Ads per URL or keyword. The limit is exact: you never get (or pay for) more. Leave empty to get every ad the library shows (a big brand can have thousands)."
          },
          "country": {
            "title": "🌍 Country (for page URLs)",
            "enum": [
              "ALL",
              "US",
              "GB",
              "CA",
              "AU",
              "FR",
              "DE",
              "ES",
              "IT",
              "NL",
              "BE",
              "CH",
              "AT",
              "PT",
              "IE",
              "SE",
              "NO",
              "DK",
              "FI",
              "PL",
              "CZ",
              "RO",
              "GR",
              "TR",
              "MA",
              "DZ",
              "TN",
              "EG",
              "SA",
              "AE",
              "QA",
              "KW",
              "IN",
              "PK",
              "ID",
              "MY",
              "SG",
              "PH",
              "TH",
              "VN",
              "JP",
              "KR",
              "BR",
              "MX",
              "AR",
              "CO",
              "CL",
              "PE",
              "ZA",
              "NG",
              "KE",
              "NZ",
              "IL",
              "UA"
            ],
            "type": "string",
            "description": "Where the ads ran, for page URLs, page names and keywords. ALL = every country. Ad Library URLs keep their own country.",
            "default": "ALL"
          },
          "onlyTotal": {
            "title": "Get only the total ad count per page",
            "type": "boolean",
            "description": "One row per URL with the total number of ads, instead of the ads themselves.",
            "default": false
          },
          "includeAboutPage": {
            "title": "Include page \"About\" information",
            "type": "boolean",
            "description": "Adds pageInfo: page name, URL, profile photo, description and the related pages of the advertiser in other countries.",
            "default": false
          },
          "isDetailsPerAd": {
            "title": "Include extra ad details (spend, reach, Instagram data)",
            "type": "boolean",
            "description": "Opens each ad's detail and adds ad_details: Instagram username and followers, page likes, category and verification, page spend and political status, and for EU ads the audience, reach by country, age and gender, payer and beneficiary. Slower (one request per ad).",
            "default": false
          },
          "activeStatus": {
            "title": "🖱️ Active status (if not in the Ad Library URL)",
            "enum": [
              "",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Ads still running, stopped ones, or both. A value already in the URL wins.",
            "default": ""
          },
          "sorting": {
            "title": "🗂️ Sorting (if not in the Ad Library URL)",
            "enum": [
              "",
              "total_impressions",
              "relevancy_monthly_grouped"
            ],
            "type": "string",
            "description": "Order of the ads. A value already in the URL wins.",
            "default": ""
          },
          "onlyAdsNewerThan": {
            "title": "Scrape ads newer than",
            "type": "string",
            "description": "Only ads active on or after this date: 2024-01-01 or \"2 months\"."
          },
          "onlyAdsOlderThan": {
            "title": "Scrape ads older than",
            "type": "string",
            "description": "Only ads active on or before this date: 2024-12-31 or \"1 year\"."
          },
          "minDaysRunning": {
            "title": "Minimum days running",
            "minimum": 1,
            "type": "integer",
            "description": "Optional. Keep only ads that ran at least this many days (first and last day included; an active ad counts until today). Long-running ads are usually the ones that work. Shorter ads are skipped and not billed; the results limit counts only the ads kept. Leave empty to keep every ad."
          },
          "enrichWithEcommerceData": {
            "title": "$ Enrich with e-commerce data",
            "type": "boolean",
            "description": "Follows each ad's links and adds the product behind them (name, price, currency, brand, image, description, rating) as ecommerceData. Billed per product found; links that are not product pages (sign-up, app, catalog templates) are free.",
            "default": false
          },
          "advertiserProfiles": {
            "title": "Advertiser profiles",
            "type": "boolean",
            "description": "One profile per advertiser (page) found in this run, saved as ADVERTISERS in the key-value store and shown in the visual report: ads saved, active / inactive, first and last dates, platforms, formats, calls to action, top landing domains, repeated texts and media, keywords. Spend, reach and countries only when Meta published them (EU and political ads), otherwise null with a note.",
            "default": false
          },
          "maxAdvertiserProfiles": {
            "title": "Maximum advertiser profiles",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Keyword searches can return hundreds of advertisers: profiles are made for this many, those with the most ads first.",
            "default": 50
          },
          "competitorComparison": {
            "title": "Competitor comparison",
            "type": "boolean",
            "description": "When the run holds at least 2 advertisers (e.g. several page URLs): one comparison (key-value store record COMPARISON + report section) of formats, platforms, ad counts, active share, keywords, landing domains and dates, with the largest observable differences. Up to 10 advertisers, the ones with the most ads.",
            "default": false
          },
          "aiAdAnalysis": {
            "title": "AI analysis per ad (your own key)",
            "type": "boolean",
            "description": "Adds aiAnalysis to each ad (up to the AI ads limit): summary, sector, product or service, selling arguments, facts (each with a quote checked against the ad) and hypotheses (labelled, with a confidence).",
            "default": false
          },
          "aiAdvertiserReport": {
            "title": "AI advertiser report (your own key)",
            "type": "boolean",
            "description": "Adds aiReport to each advertiser profile: overview, main offers, recurring messages, facts and hypotheses. Needs \"Advertiser profiles\".",
            "default": false
          },
          "aiProvider": {
            "title": "AI provider",
            "enum": [
              "openai",
              "anthropic",
              "gemini"
            ],
            "type": "string",
            "description": "The provider of your API key.",
            "default": "openai"
          },
          "aiApiKey": {
            "title": "AI API key",
            "type": "string",
            "description": "Your own key for the provider above (stored encrypted by Apify, never logged or saved in the results). Required when an AI option is on: without a valid key the run stops before scraping and nothing is charged."
          },
          "aiModel": {
            "title": "AI model",
            "type": "string",
            "description": "Optional model id. Leave empty for the default: gpt-6-luna (OpenAI), claude-haiku-5-5 (Anthropic), gemini-3.5-flash-lite (Gemini)."
          },
          "aiMaxAds": {
            "title": "Maximum ads analysed by AI",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Cost control: at most this many ads are sent to the AI per run. The other ads are saved as usual with aiAnalysis.status = skipped.",
            "default": 20
          },
          "aiMaxAdvertiserReports": {
            "title": "Maximum AI advertiser reports",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Cost control: at most this many advertiser reports per run.",
            "default": 10
          },
          "aiMaxOutputTokens": {
            "title": "Maximum output tokens per AI answer",
            "minimum": 200,
            "maximum": 4000,
            "type": "integer",
            "description": "Cost control: the longest answer the AI may write for one ad or advertiser. Ad text sent is capped at 2,000 characters.",
            "default": 800
          },
          "monitorNewAds": {
            "title": "Only new ads since the last run (monitoring)",
            "type": "boolean",
            "description": "Keeps the ad IDs seen for each search (same URL and filters) in a named key-value store of your account. The first run is the baseline (every ad found is saved); later runs save and bill only ads not seen before, plus a MONITORING_CHANGES record (new ads, ads now inactive, ads no longer shown when the search was read to the end). The results limit then counts the ads read, not the ads saved.",
            "default": false
          },
          "monitoringStoreName": {
            "title": "Monitoring store name",
            "type": "string",
            "description": "Named key-value store in your Apify account (lower-case letters, digits and dashes). Use a different name per project or client to keep separate histories.",
            "default": "fb-ads-monitoring"
          },
          "failRunOnError": {
            "title": "Mark the run as failed on a configuration error",
            "type": "boolean",
            "description": "By default a rejected AI key, an exhausted AI account or a monitoring store problem ends the run as SUCCEEDED with a clear message (nothing more is charged). So does a run where Facebook refused every input, or no input or proxy setting was usable (RUN_SUMMARY status BLOCKED or CUSTOMER_ERROR, nothing charged). Turn on to get FAILED instead (for alerts in integrations). Technical errors always end the run FAILED.",
            "default": false
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Leave as it is (no proxy): the Actor reads the Ad Library directly. A page Facebook refuses is not tried again and not charged; a technical error gets at most 2 new tries on the same connection. A RESIDENTIAL group set here is not used (the price covers the Actor's default connection).",
            "default": {
              "useApifyProxy": false
            }
          },
          "runTag": {
            "title": "Run tag",
            "type": "string",
            "description": "Optional label (e.g. competitor-watch-week-45) copied to every row as runTag, to tell runs apart when you merge datasets. Leave empty for no tag."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}