{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ad Library Scraper (Meta Ads Library)",
    "description": "Scrape the Facebook Ads Library (Meta Ad Library) by keyword, page ID or URL: ad copy, images, videos, CTAs, landing pages, dates, platforms and page info, plus EU reach, targeting and payer data. Every ad in a group, deduplicated. No login, cookies or proxy setup.",
    "version": "0.1",
    "x-build-id": "evR1APiU4anO2CuIt"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/xmolodtsov~facebook-ads-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-xmolodtsov-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/xmolodtsov~facebook-ads-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-xmolodtsov-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/xmolodtsov~facebook-ads-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-xmolodtsov-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": {
          "searchTerms": {
            "title": "Search terms",
            "type": "array",
            "description": "Keywords to search the Ad Library for, such as a brand (nike), a product (running shoes) or a topic. Each term runs as its own search. Fill in at least one search term, page ID or Ad Library URL.",
            "items": {
              "type": "string"
            }
          },
          "pageIds": {
            "title": "Facebook page IDs",
            "type": "array",
            "description": "Numeric Facebook page IDs; returns the ads that page runs. Copy the number after view_all_page_id= in the page's Ad Library URL. Page names don't work: Meta resolves them only for logged-in visitors.",
            "items": {
              "type": "string"
            }
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "Where the ads were shown: ALL, or one 2-letter country code such as US, GB, DE, FR or BR. Applies to search terms and page IDs. For several countries, paste one Ad Library URL per country.",
            "default": "ALL"
          },
          "maxItems": {
            "title": "Maximum ads",
            "minimum": 1,
            "type": "integer",
            "description": "Stop after this many unique ads across the whole run. You pay only for ads delivered. Free Apify plan: capped at 10 ads per run (and 5 runs per calendar month), a limit set by the developer, not by Apify.",
            "default": 100
          },
          "scrapeAdDetails": {
            "title": "Scrape ad details",
            "type": "boolean",
            "description": "Adds the ad's detail panel: EU total reach with the age, gender and country breakdown, targeting, payer and beneficiary, and the advertiser's page info (likes, Instagram, category). Meta publishes reach and targeting only for ads shown in the EU. Slower, no extra charge.",
            "default": false
          },
          "urls": {
            "title": "Ad Library URLs",
            "type": "array",
            "description": "Search, page or single-ad (?id=) URLs copied from facebook.com/ads/library. Each URL keeps its own filters (country, ad type, status, media, dates, sort, language); the Country field and the filter fields below don't apply to URLs.",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "adType": {
            "title": "Ad category",
            "enum": [
              "all",
              "political_and_issue_ads",
              "housing_ads",
              "employment_ads",
              "credit_ads"
            ],
            "type": "string",
            "description": "Meta's Ad Library category. Only political and issue ads carry spend and impression ranges.",
            "default": "all"
          },
          "activeStatus": {
            "title": "Status",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "Ads running now, ads that have stopped, or both.",
            "default": "active"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "all",
              "image",
              "video",
              "meme",
              "image_and_meme",
              "none"
            ],
            "type": "string",
            "description": "Only ads with this kind of creative.",
            "default": "all"
          },
          "searchType": {
            "title": "Keyword match",
            "enum": [
              "keyword_unordered",
              "keyword_exact_phrase"
            ],
            "type": "string",
            "description": "How search terms match the ad text: any of the words, or the exact phrase. Applies to search terms only.",
            "default": "keyword_unordered"
          },
          "startDate": {
            "title": "Shown from",
            "type": "string",
            "description": "Only ads that had impressions on or after this date (YYYY-MM-DD), not only ads that started then. Leave empty for no limit."
          },
          "endDate": {
            "title": "Shown until",
            "type": "string",
            "description": "Only ads that had impressions on or before this date (YYYY-MM-DD). Leave empty for no limit."
          },
          "sortBy": {
            "title": "Sort by",
            "enum": [
              "impressions_desc",
              "impressions_asc",
              "most_recent"
            ],
            "type": "string",
            "description": "Result order. Most recent is Meta's month-grouped order. Meta reports impressions only for political and issue ads, so low to high reorders only those.",
            "default": "impressions_desc"
          },
          "maxItemsPerQuery": {
            "title": "Maximum ads per query",
            "minimum": 1,
            "type": "integer",
            "description": "Optional cap per search term, page ID or URL, so one big query can't use up the whole run. Leave empty for no cap."
          },
          "expandAdGroups": {
            "title": "Every ad in a group",
            "type": "boolean",
            "description": "Meta groups near-identical ads into one result (\"24 ads use this creative\"). On: one row per ad, every variant included. Off: one row per group. Each delivered ad is priced the same.",
            "default": true
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}