{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ad Library Scraper",
    "description": "Search Meta's public Ad Library without login or API key. Get ad text, creatives, spend range, impressions, platforms and funding entity, by keyword or for a specific Facebook Page. $0.0008 per ad plus $0.005 per run start.",
    "version": "2.0",
    "x-build-id": "jNstFPbxtStcv6uVI"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/santamaria-automations~facebook-ad-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-santamaria-automations-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/santamaria-automations~facebook-ad-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-santamaria-automations-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/santamaria-automations~facebook-ad-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-santamaria-automations-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": {
          "searchUrls": {
            "title": "Ad Library URLs",
            "type": "array",
            "description": "Paste any Facebook Ad Library URL - every filter in the URL (country, ad_type, active_status, media_type, publisher_platforms, content_languages, page_ids, start_date, search_type, sort_data) is auto-parsed. Easiest way to scrape: open Ad Library in your browser, apply filters, copy URL, paste here.",
            "items": {
              "type": "string"
            }
          },
          "searchQueries": {
            "title": "Search Keywords",
            "type": "array",
            "description": "Keywords to search in the Meta Ad Library (e.g. 'Nike shoes', 'Tesla Model 3'). Each runs as a separate search. Results are deduplicated across all queries. If you give no searchUrls, searchQueries, pageIds or advertiserNames, the default keyword 'nike' is searched.",
            "items": {
              "type": "string"
            },
            "default": [
              "nike"
            ]
          },
          "pageIds": {
            "title": "Page IDs",
            "type": "array",
            "description": "Facebook Page IDs to fetch all ads for (numeric IDs, not usernames). Example: 15087023444 (Nike). Combine with searchQueries or use standalone.",
            "items": {
              "type": "string"
            }
          },
          "advertiserNames": {
            "title": "Advertiser Names",
            "type": "array",
            "description": "Brand/advertiser names - searched as exact phrases. Use this when you know the advertiser by name but not their Page ID.",
            "items": {
              "type": "string"
            }
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code (e.g. 'US', 'GB', 'DE'). Use 'ALL' to search globally. Applied to searchQueries / pageIds / advertiserNames. Ignored when using searchUrls (URL takes precedence).",
            "default": "ALL"
          },
          "adType": {
            "title": "Ad Type",
            "enum": [
              "ALL",
              "POLITICAL_AND_ISSUE_ADS",
              "HOUSING_ADS",
              "EMPLOYMENT_ADS",
              "CREDIT_ADS"
            ],
            "type": "string",
            "description": "Type of ads to return.",
            "default": "ALL"
          },
          "activeStatus": {
            "title": "Active Status",
            "enum": [
              "ALL",
              "ACTIVE",
              "INACTIVE"
            ],
            "type": "string",
            "description": "Filter by whether the ad is currently running.",
            "default": "ALL"
          },
          "mediaType": {
            "title": "Media Type",
            "enum": [
              "ALL",
              "IMAGE",
              "VIDEO",
              "MEME",
              "NONE"
            ],
            "type": "string",
            "description": "Filter by creative media format.",
            "default": "ALL"
          },
          "publisherPlatforms": {
            "title": "Publisher Platforms",
            "type": "array",
            "description": "Restrict to ads running on specific Meta platforms.",
            "items": {
              "type": "string",
              "enum": [
                "facebook",
                "instagram",
                "messenger",
                "audience_network",
                "whatsapp",
                "threads",
                "oculus"
              ],
              "enumTitles": [
                "Facebook",
                "Instagram",
                "Messenger",
                "Audience Network",
                "WhatsApp",
                "Threads",
                "Oculus"
              ]
            }
          },
          "contentLanguages": {
            "title": "Content Languages",
            "type": "array",
            "description": "ISO 639-1 language codes (e.g. 'en', 'de', 'es'). Returns only ads in these languages.",
            "items": {
              "type": "string"
            }
          },
          "searchType": {
            "title": "Search Match Mode",
            "enum": [
              "keyword_unordered",
              "keyword_exact_phrase"
            ],
            "type": "string",
            "description": "How keywords match ad text. 'Exact phrase' is stricter; 'Unordered' is broader.",
            "default": "keyword_unordered"
          },
          "sortBy": {
            "title": "Sort By",
            "enum": [
              "",
              "total_impressions_DESC",
              "total_impressions_ASC",
              "time_active_DESC",
              "time_active_ASC"
            ],
            "type": "string",
            "description": "Result ordering. Meta's Ad Library can sort by impressions or by time active (it has no newest-first sort). Impressions are only disclosed for political and issue ads; for other ads the default relevancy order is usually the most useful.",
            "default": ""
          },
          "startDateMin": {
            "title": "Earliest Start Date",
            "type": "string",
            "description": "Only return ads that started running on or after this date (YYYY-MM-DD)."
          },
          "startDateMax": {
            "title": "Latest Start Date",
            "type": "string",
            "description": "Only return ads that started running on or before this date (YYYY-MM-DD)."
          },
          "maxAdsPerInput": {
            "title": "Max Ads per Source",
            "minimum": 1,
            "type": "integer",
            "description": "Maximum ads per searchUrl / keyword / pageId / advertiser. Meta serves 10 ads per page.",
            "default": 20
          },
          "maxResults": {
            "title": "Max Total Results",
            "minimum": 0,
            "type": "integer",
            "description": "Hard cap on total ads across all sources. Set to 0 for unlimited.",
            "default": 0
          },
          "includeAdDetails": {
            "title": "Include EU Ad Transparency Details",
            "type": "boolean",
            "description": "Add EU ad transparency details to every ad: total EU reach, reach by country, age and gender, targeting (ages, gender, locations), payer and beneficiary. Only ads delivered in the EU have reach and targeting data; other ads get the status not_eu. Makes the run slower because every ad needs one extra lookup.",
            "default": false
          },
          "maxIPRotations": {
            "title": "Retries on Rate Limit",
            "minimum": 0,
            "maximum": 50,
            "type": "integer",
            "description": "Meta rate-limits IPs on busy queries. On a rate limit the scraper starts a fresh session and retries. Default 5; increase up to 50 for high-volume runs, set 0 to disable.",
            "default": 5
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}