{
  "openapi": "3.0.1",
  "info": {
    "title": "Meta Ad Library Scraper — Facebook & Instagram Ads, EU Reach",
    "description": "Scrape Facebook & Instagram ads from Meta's Ad Library by keyword, brand name, page or link: copy, CTA, landing page, media, days running. Add EU reach & audience, product prices, image copies and only-new-ads monitoring. No login. Export to CSV, Excel or JSON.",
    "version": "0.1",
    "x-build-id": "ezUZenUziOCZ7oKVf"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/lergassy~meta-ad-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-lergassy-meta-ad-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/lergassy~meta-ad-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-lergassy-meta-ad-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/lergassy~meta-ad-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-lergassy-meta-ad-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": {
          "queries": {
            "title": "🔍 Search keywords",
            "type": "array",
            "description": "Words or brand names to search the Ad Library for, one per line. Every ad whose text, advertiser or link matches is returned. Leave everything empty to run a 10-ad demo search for <code>nike</code>.",
            "items": {
              "type": "string"
            }
          },
          "advertiserNames": {
            "title": "🏷️ Advertiser names (brands)",
            "type": "array",
            "description": "Brand or page names, for example <code>Shopify</code> or <code>Gymshark</code>. Each name is looked up in the Ad Library's own name search and every ad of the matching page(s) is returned. No need to find page IDs yourself; the lookup is not charged.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "pageIds": {
            "title": "📄 Facebook page IDs",
            "type": "array",
            "description": "Numeric page IDs to pull every ad of one advertiser. The ID is the number after <code>view_all_page_id=</code> in an Ad Library link, and it is also returned as <code>pageId</code> on every row.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "adIds": {
            "title": "🆔 Ad Library IDs (single ads)",
            "type": "array",
            "description": "The Library ID of one ad (the number after <code>?id=</code> in its Ad Library link). Use it to refresh one ad's status, run dates and EU reach. An ID that no longer exists comes back as a free <code>not-found</code> row.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "startUrls": {
            "title": "🔗 Ad Library or Facebook page links",
            "type": "array",
            "description": "Paste links straight from your browser: an Ad Library search (<code>…/ads/library/?q=…</code>), an advertiser's Ad Library page (<code>…view_all_page_id=…</code>), a single ad (<code>…/ads/library/?id=…</code>) or a Facebook page (<code>facebook.com/nike</code>). Country, status, ad type, media type and exact-phrase settings in the link are kept for that link.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "resultType": {
            "title": "📦 Return",
            "enum": [
              "ads",
              "advertisers"
            ],
            "type": "string",
            "description": "<b>Ads</b> (default): one row per ad. <b>Advertisers</b>: one row per Facebook page matching your names or keywords — page ID, likes, category, blue tick, Instagram handle and followers, Ad Library link — to find the right advertiser before scraping its ads.",
            "default": "ads"
          },
          "maxAdvertisersPerName": {
            "title": "Pages per advertiser name",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "A name like <code>Nike</code> matches several pages (Nike, Nike Football, Nike Running…). How many of the best matches to take ads from.",
            "default": 3
          },
          "onlyMatchingAdvertisers": {
            "title": "Only pages whose name contains the text",
            "type": "boolean",
            "description": "Drop name-search suggestions whose page name does not contain your text (Meta also suggests related brands).",
            "default": false
          },
          "country": {
            "title": "🌍 Country",
            "type": "string",
            "description": "Two-letter country code of the audience the ads were shown to, for example <code>US</code>, <code>GB</code>, <code>DE</code>, or <code>ALL</code> for every country. Meta indexes ads per country, so this changes which ads exist, not just how they are filtered.",
            "default": "US"
          },
          "countries": {
            "title": "Several countries",
            "type": "array",
            "description": "Search several countries at once, for example <code>DE</code>, <code>FR</code>, <code>IT</code>. Overrides the single country above.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "targetedCountryOnly": {
            "title": "Only ads targeting that country",
            "type": "boolean",
            "description": "Keep ads the advertiser targeted at the country, not ads that only reached it.",
            "default": false
          },
          "activeStatus": {
            "title": "🟢 Ad status",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "Whether to return ads that are still running, ads that have stopped, or both.",
            "default": "active"
          },
          "adType": {
            "title": "🗳️ Ad category",
            "enum": [
              "all",
              "political",
              "housing",
              "employment",
              "credit"
            ],
            "type": "string",
            "description": "All ads, or one of the special categories Meta keeps a separate shelf for. Spend, impressions and reach ranges are published only for political and social-issue ads.",
            "default": "all"
          },
          "mediaType": {
            "title": "🖼️ Media type",
            "enum": [
              "all",
              "image",
              "video",
              "meme",
              "image_and_meme",
              "none"
            ],
            "type": "string",
            "description": "Keep only ads of one format.",
            "default": "all"
          },
          "platforms": {
            "title": "📱 Platforms",
            "type": "array",
            "description": "Limit to ads shown on particular Meta surfaces. Leave empty for all of them.",
            "items": {
              "type": "string",
              "enum": [
                "FACEBOOK",
                "INSTAGRAM",
                "MESSENGER",
                "AUDIENCE_NETWORK",
                "THREADS",
                "WHATSAPP"
              ],
              "enumTitles": [
                "Facebook",
                "Instagram",
                "Messenger",
                "Audience Network",
                "Threads",
                "WhatsApp"
              ]
            },
            "default": []
          },
          "languages": {
            "title": "🗣️ Ad languages",
            "type": "array",
            "description": "Two-letter language codes of the ad text, for example <code>en</code>, <code>es</code>, <code>de</code>. Leave empty for any language.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "keywordMatch": {
            "title": "Keyword matching",
            "enum": [
              "any_words",
              "exact_phrase"
            ],
            "type": "string",
            "description": "<b>Any of the words</b> is the Ad Library's default. <b>Exact phrase</b> keeps only ads that contain the words together, in that order.",
            "default": "any_words"
          },
          "sortBy": {
            "title": "Sort order",
            "enum": [
              "relevance",
              "most_impressions",
              "least_impressions"
            ],
            "type": "string",
            "description": "Relevance is Meta's default. <b>Most impressions</b> puts the ads Meta counts as most seen first — the quickest way to the winning creatives of a niche.",
            "default": "relevance"
          },
          "period": {
            "title": "📅 Launched in the last…",
            "enum": [
              "",
              "last24h",
              "last7d",
              "last14d",
              "last30d",
              "last90d"
            ],
            "type": "string",
            "description": "A rolling window — handy on a schedule. Ignored when you set a start date below.",
            "default": ""
          },
          "startDate": {
            "title": "📅 Ads started after",
            "type": "string",
            "description": "Only ads that began running on or after this date, as <code>YYYY-MM-DD</code> (or a span such as <code>30 days</code>)."
          },
          "endDate": {
            "title": "📅 Ads started before",
            "type": "string",
            "description": "Only ads that began running on or before this date, as <code>YYYY-MM-DD</code>."
          },
          "longRunningDays": {
            "title": "Long-running threshold (days)",
            "minimum": 1,
            "type": "integer",
            "description": "An ad shown for at least this many days gets <code>isLongRunning: true</code> — advertisers rarely keep paying for an ad that does not work.",
            "default": 30
          },
          "includeEuReach": {
            "title": "🇪🇺 EU reach and audience per ad",
            "type": "boolean",
            "description": "Opens each ad's \"See ad details\" panel: total EU reach, reach by country × age × gender, the audience (age range, gender, locations), payer and beneficiary, plus the advertiser facts below. Paid add-on, charged only on ads that come back with EU/UK figures — an ad never shown in the EU costs nothing extra. Works best with an EU country (DE, FR, IT, ES…).",
            "default": false
          },
          "includeAdvertiserInfo": {
            "title": "👤 Advertiser facts (free)",
            "type": "boolean",
            "description": "About text, category, blue tick, Instagram username and followers, cover photo, restricted flag and whether the page ran political ads. One extra request per advertiser, not per ad — free.",
            "default": false
          },
          "enrichLandingPage": {
            "title": "🛒 Read the landing page",
            "type": "boolean",
            "description": "Follows the ad's link to where it really lands and reads the final URL, page title and description, site name and — on product pages — product name, price, currency and brand. Paid add-on, charged once per landing URL per run; ads sharing a link reuse it free; a page that cannot be read is free.",
            "default": false
          },
          "downloadImages": {
            "title": "💾 Save image copies",
            "enum": [
              "none",
              "first",
              "all"
            ],
            "type": "string",
            "description": "Meta's image links expire after a few days. This copies the ad images (and the still frame of video ads) into a key-value store you own and puts permanent links in <code>imageFiles</code>. A file already saved for that ad is linked, not re-billed. Video files themselves are not copied.",
            "default": "none"
          },
          "mediaStoreName": {
            "title": "Image store name",
            "type": "string",
            "description": "Name of the key-value store for image copies, so they stay across runs (for example <code>competitor-ads</code>). Empty = this run's own store."
          },
          "onlyNewAds": {
            "title": "🆕 Only ads not seen before",
            "type": "boolean",
            "description": "For schedules: skip every ad an earlier run with the same inputs already delivered — not returned, not charged. Rows carry <code>firstSeenAt</code> and <code>lastSeenAt</code>.",
            "default": false
          },
          "includeEndedAds": {
            "title": "Report ads that ended",
            "type": "boolean",
            "description": "Adds a free <code>ended</code> row for each remembered ad that a complete scan no longer finds (stopped or removed).",
            "default": false
          },
          "stateStoreName": {
            "title": "Monitoring memory name",
            "type": "string",
            "description": "Name of the memory store, so several tasks can share it or one task can keep it when you change inputs. Empty = named after your inputs."
          },
          "summaryRows": {
            "title": "Add advertiser summary rows (free)",
            "type": "boolean",
            "description": "One extra free row per advertiser at the end: ads delivered, live ads, longest-running ad, average days shown, formats, platforms, landing domains, distinct copies. The same summary is always saved to the <code>ADVERTISER_SUMMARY</code> record.",
            "default": false
          },
          "runTag": {
            "title": "Run tag",
            "type": "string",
            "description": "Any label you want copied onto every row (for example a client or campaign name), to tell runs apart in one sheet."
          },
          "maxAds": {
            "title": "💯 Maximum ads",
            "minimum": 1,
            "type": "integer",
            "description": "Hard cap for the whole run. It is checked before every request, so the run stops at this number and never bills you past it.",
            "default": 30
          },
          "maxAdsPerQuery": {
            "title": "Maximum ads per keyword or page",
            "minimum": 1,
            "type": "integer",
            "description": "Optional per-target cap, so one broad keyword cannot eat the whole run."
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Meta serves the Ad Library to residential addresses only; from a datacentre address it answers with an empty response. Leave this on the default — the proxy is included in the price.",
            "default": {
              "useApifyProxy": true,
              "apifyProxyGroups": [
                "RESIDENTIAL"
              ],
              "apifyProxyCountry": "US"
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}