{
  "openapi": "3.0.1",
  "info": {
    "title": "Meta (Facebook) Ad Library Scraper - Fast & Reliable",
    "description": "Scrape Meta ads in seconds - no fluff, just instant access to the ad data and insights you need. \n\nGet detailed ad information including title, description, images, videos, CTA, Social platform and metadata",
    "version": "0.0",
    "x-build-id": "ztsJEgP03lGwSNwgf"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/whoareyouanas~meta-ad-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-whoareyouanas-meta-ad-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/whoareyouanas~meta-ad-scraper/runs": {
      "post": {
        "operationId": "runs-sync-whoareyouanas-meta-ad-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/whoareyouanas~meta-ad-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-whoareyouanas-meta-ad-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": {
          "targetUrl": {
            "title": "Facebook Ad Library URL (Direct)",
            "pattern": "^(https?://)?(www\\.)?facebook\\.com/ads/library/.*$",
            "type": "string",
            "description": "Paste the full Facebook Ad Library URL directly. If provided, all parameter fields below are ignored. Leave empty to build the URL from parameters instead."
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code for ad targeting (e.g. US, IN, IT, GB). Required when not using a direct URL.",
            "default": "US"
          },
          "searchQuery": {
            "title": "Search Query (Keyword)",
            "type": "string",
            "description": "Keyword search query (e.g. 'nike', 'adidas shoes'). This searches across all ads by keyword."
          },
          "pageId": {
            "title": "Facebook Page ID",
            "type": "string",
            "description": "Numeric Facebook Page ID to view all ads from a specific page (e.g. 108047081396228). You can find this in the URL when viewing a page's ads.",
            "default": ""
          },
          "adId": {
            "title": "Specific Ad ID",
            "type": "string",
            "description": "Numeric ID of a specific ad to look up (e.g. 1191898553123641)."
          },
          "activeStatus": {
            "title": "Ad Status",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "Filter by ad campaign status.",
            "default": "active"
          },
          "adType": {
            "title": "Ad Type",
            "enum": [
              "all",
              "political_and_issue_ads",
              "housing",
              "employment",
              "credit"
            ],
            "type": "string",
            "description": "Filter by type of ads.",
            "default": "all"
          },
          "mediaType": {
            "title": "Media Type",
            "enum": [
              "all",
              "image",
              "video",
              "meme"
            ],
            "type": "string",
            "description": "Filter by media format.",
            "default": "all"
          },
          "isTargetedCountry": {
            "title": "Targeted Country Only",
            "type": "boolean",
            "description": "If true, only show ads specifically targeting the selected country.",
            "default": false
          },
          "contentLanguages": {
            "title": "Content Languages",
            "type": "array",
            "description": "Filter by content language codes (ISO 639-1, e.g. 'en', 'it', 'hi'). Leave empty for all languages.",
            "items": {
              "type": "string"
            }
          },
          "sortMode": {
            "title": "Sort By",
            "enum": [
              "total_impressions",
              "relevance",
              "start_date"
            ],
            "type": "string",
            "description": "Sort metric for results.",
            "default": "total_impressions"
          },
          "sortDirection": {
            "title": "Sort Direction",
            "enum": [
              "desc",
              "asc"
            ],
            "type": "string",
            "description": "Sort order for results.",
            "default": "desc"
          },
          "maxConcurrency": {
            "title": "Max Concurrency",
            "minimum": 1,
            "maximum": 10,
            "type": "integer",
            "description": "Number of browser tabs to run in parallel. Keep at 1 for stability. Increase to 2-3 only if you need faster scraping and have sufficient memory. Higher values increase memory usage.",
            "default": 1
          },
          "requestHandlerTimeoutSecs": {
            "title": "Page Timeout (seconds)",
            "minimum": 60,
            "maximum": 1200,
            "type": "integer",
            "description": "Maximum time to wait for a page to load and scrape all ads. Pages with 200+ ads need 600-900 seconds. Default of 900 seconds (15 minutes) handles large datasets.",
            "default": 900
          },
          "proxyUrl": {
            "title": "Your Proxy URL (Recommended for 99% results)",
            "type": "string",
            "description": "Add your Apify Proxy URL to get 99% of all ads! Format: http://groups-RESIDENTIAL:YOUR_APIFY_TOKEN@proxy.apify.com:8000. Get your token from Apify Console → Proxy → Groups tab → RESIDENTIAL link  → Copy link. External proxies (BrightData, Oxylabs) also work. Or connect with us directly if you don't want to use Proxy but want 99% of all ads."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}