{
  "openapi": "3.0.1",
  "info": {
    "title": "Meta (Facebook & Instagram) Ad Library Scraper",
    "description": "Scrapes Meta's public Ad Library and returns structured ad data. Four lookup modes (page_id, page_url, keyword, batch), opt-in pagination, schema-validated output.",
    "version": "0.2",
    "x-build-id": "6oGVkLApYDexcxSkI"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/jaybird~meta-ad-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-jaybird-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/jaybird~meta-ad-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-jaybird-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/jaybird~meta-ad-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-jaybird-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",
        "required": [
          "search_mode"
        ],
        "properties": {
          "search_mode": {
            "title": "Search mode",
            "enum": [
              "page_id",
              "page_url",
              "keyword",
              "batch"
            ],
            "type": "string",
            "description": "How to look up ads. page_id and page_url target a specific advertiser; keyword and batch use Meta's keyword search.",
            "default": "keyword"
          },
          "page_id": {
            "title": "Facebook Page ID (numeric)",
            "type": "string",
            "description": "Required when search_mode = page_id. Numeric ID, e.g. 142023025844028."
          },
          "page_url": {
            "title": "Facebook Page URL",
            "type": "string",
            "description": "Required when search_mode = page_url. e.g. https://www.facebook.com/PetsOnBroadway"
          },
          "query": {
            "title": "Keyword / business name",
            "type": "string",
            "description": "Required when search_mode = keyword. Free-text search across all advertisers."
          },
          "queries": {
            "title": "Batch queries",
            "type": "array",
            "description": "Required when search_mode = batch. One keyword per line. Each query produces its own search results; overlapping queries are NOT deduplicated within a run.",
            "items": {
              "type": "string"
            }
          },
          "region": {
            "title": "Region (ISO 3166-1 alpha-2)",
            "type": "string",
            "description": "Country to filter Meta's Ad Library results to. Defaults to US.",
            "default": "US"
          },
          "active_only": {
            "title": "Active ads only",
            "type": "boolean",
            "description": "When true, returns only currently-active ads. When false, includes inactive (stopped) ads.",
            "default": true
          },
          "media_type": {
            "title": "Media type filter",
            "enum": [
              "all",
              "image",
              "video"
            ],
            "type": "string",
            "description": "Filter to image-only or video-only creatives, or include all.",
            "default": "all"
          },
          "match_type": {
            "title": "Keyword match type",
            "enum": [
              "broad",
              "exact"
            ],
            "type": "string",
            "description": "How Meta should match the keyword/business name. 'broad' (default) matches ads containing all the words in any order (Meta's search_type=keyword_unordered). 'exact' matches ads containing the exact phrase (Meta's search_type=keyword_exact_phrase). Ignored when search_mode = page_id.",
            "default": "broad"
          },
          "max_ads_per_advertiser": {
            "title": "Max ads per advertiser",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Hard cap on ads returned for each query. With pagination off, first SSR page (~30 ads) only.",
            "default": 30
          },
          "follow_pagination": {
            "title": "Follow pagination cursors",
            "type": "boolean",
            "description": "When false, returns only the first SSR page (~30 ads). When true, walks end_cursor up to max_ads_per_advertiser.",
            "default": false
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}