{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ad Library Scraper",
    "description": "Scrapes ads from the Facebook Ad Library. Accepts search URLs or Facebook page URLs and returns structured ad data.",
    "version": "0.1",
    "x-build-id": "eL1ErXIZYnbiRbQOf"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/practicaltools~facebook-ad-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-practicaltools-facebook-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/practicaltools~facebook-ad-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-practicaltools-facebook-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/practicaltools~facebook-ad-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-practicaltools-facebook-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": {
          "keyword": {
            "title": "Keyword search",
            "type": "string",
            "description": "Searches the whole Ad Library for this term, like typing it into the Ad Library search box. Leave empty to skip the keyword search."
          },
          "pages": {
            "title": "Advertiser pages",
            "type": "array",
            "description": "Every ad each advertiser is running. One per line: a page URL (https://www.facebook.com/tesla), a handle (tesla), a numeric page ID, or an Ad Library link that contains view_all_page_id.",
            "items": {
              "type": "string"
            }
          },
          "urls": {
            "title": "Ad Library URLs",
            "type": "array",
            "description": "Searches copied straight from the Ad Library website, one per line. Everything in the URL is kept; filters you change below are added only if the URL does not already set them. A Facebook page URL pasted here works like an advertiser page.",
            "items": {
              "type": "string"
            }
          },
          "keywordWithinPages": {
            "title": "Search the keyword inside the advertiser pages' ads",
            "type": "boolean",
            "description": "Off: the keyword is a search of its own and the pages return all their ads. On: the keyword becomes a filter, so you get only the pages' ads that match it (e.g. 'Model Y' inside Tesla's ads) and no separate keyword search.",
            "default": false
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code (e.g. US, GB, DE) or ALL.",
            "default": "ALL"
          },
          "activeStatus": {
            "title": "Active status",
            "enum": [
              "all",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Only currently running ads, only stopped ads, or both.",
            "default": "all"
          },
          "adType": {
            "title": "Ad category",
            "enum": [
              "all",
              "political_and_issue_ads",
              "housing_ads",
              "employment_ads",
              "credit_ads"
            ],
            "type": "string",
            "description": "All ads, or only a regulated category. Political and issue ads carry spend and reach estimates.",
            "default": "all"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "all",
              "image",
              "video",
              "meme",
              "none"
            ],
            "type": "string",
            "description": "Filter by creative type.",
            "default": "all"
          },
          "datePreset": {
            "title": "Date range",
            "enum": [
              "",
              "last24h",
              "last7d",
              "last14d",
              "last30d",
              "last90d"
            ],
            "type": "string",
            "description": "Only ads that were running at some point in this window. Ignored when explicit dates are given below.",
            "default": ""
          },
          "startDateMin": {
            "title": "Running on or after",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "YYYY-MM-DD. Only ads that were running on or after this day."
          },
          "startDateMax": {
            "title": "Running on or before",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "YYYY-MM-DD. Only ads that were running on or before this day."
          },
          "publisherPlatforms": {
            "title": "Platforms",
            "type": "array",
            "description": "Only ads shown on these Meta platforms. Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "facebook",
                "instagram",
                "audience_network",
                "messenger",
                "threads"
              ],
              "enumTitles": [
                "Facebook",
                "Instagram",
                "Audience Network",
                "Messenger",
                "Threads"
              ]
            },
            "default": []
          },
          "contentLanguages": {
            "title": "Ad languages",
            "type": "array",
            "description": "ISO 639-1 codes, one per line (en, es, de, fr, pt…). Leave empty for all languages.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "searchType": {
            "title": "Keyword matching",
            "enum": [
              "keyword_unordered",
              "keyword_exact_phrase"
            ],
            "type": "string",
            "description": "'Any of the words' matches ads containing the words in any order. 'Exact phrase' matches the words together, in order.",
            "default": "keyword_unordered"
          },
          "sortBy": {
            "title": "Sort order",
            "enum": [
              "impressions_desc",
              "impressions_asc",
              "start_date_desc",
              "start_date_asc"
            ],
            "type": "string",
            "description": "Sent to Facebook as the sort preference. Note: Facebook's server-rendered results currently ignore it and come back in Facebook's own relevance order.",
            "default": "impressions_desc"
          },
          "limitPerSource": {
            "title": "Max ads per source",
            "minimum": 0,
            "type": "integer",
            "description": "Maximum ads to collect for each keyword, page, or URL. Set 0 to collect all of them.",
            "default": 10
          },
          "maxItems": {
            "title": "Max ads in total",
            "minimum": 0,
            "type": "integer",
            "description": "Stop the run after this many ads across all sources. 0 = no limit. Useful to cap cost when scraping many pages.",
            "default": 0
          },
          "outputMode": {
            "title": "Rows",
            "enum": [
              "ad",
              "card"
            ],
            "type": "string",
            "description": "'One row per ad' flattens the first creative card into the row and nests every card under 'cards'. 'One row per creative card' emits carousel cards as separate rows.",
            "default": "ad"
          },
          "includePageSummary": {
            "title": "Add a summary row per advertiser page",
            "type": "boolean",
            "description": "For each page in 'Facebook pages', add one row with the total number of matching ads, how many were collected, active count, platform breakdown, and earliest/latest start dates. See the 'Pages' view in the Output tab.",
            "default": false
          },
          "includeEuTransparency": {
            "title": "Add EU transparency and payer details",
            "type": "boolean",
            "description": "Fetch each ad's details page: EU reach with a country / age / gender breakdown, targeting (locations, age range, gender), payer and beneficiary, Instagram handle and followers, page verification. Costs one extra request per ad, so runs take longer.",
            "default": false
          },
          "includeRawData": {
            "title": "Include raw Facebook data",
            "type": "boolean",
            "description": "Attach the untouched Facebook ad object to every row as 'rawData'. Increases dataset size.",
            "default": false
          },
          "runTag": {
            "title": "Run tag",
            "type": "string",
            "description": "Free text copied into the 'runTag' column of every row. Handy for joining several runs in a spreadsheet."
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Optional. The Ad Library is a public tool and normally works without a proxy. Use residential proxies only if you encounter blocks."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}