{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ad Library Scraper — Anti-Block, No Login",
    "description": "Scrape Meta Ad Library ads into structured datasets with creatives, copy, CTAs, landing URLs, platforms, dates, spend signals, and optional AI competitive analysis.",
    "version": "1.5",
    "x-build-id": "HCndvM9ybIT0ZeQLL"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/viralanalyzer~facebook-ads-library/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-viralanalyzer-facebook-ads-library",
        "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/viralanalyzer~facebook-ads-library/runs": {
      "post": {
        "operationId": "runs-sync-viralanalyzer-facebook-ads-library",
        "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/viralanalyzer~facebook-ads-library/run-sync": {
      "post": {
        "operationId": "run-sync-viralanalyzer-facebook-ads-library",
        "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": [
          "searchQuery"
        ],
        "properties": {
          "searchQuery": {
            "title": "Advertiser name, Ad Library URL, or Page ID",
            "type": "string",
            "description": "Three ways to search: (1) an advertiser/page name or keyword — e.g. 'Nike', 'Magazine Luiza', 'coffee subscription'; (2) paste a Meta Ad Library URL straight from your browser — every filter in that URL is honoured; (3) a numeric Page ID — e.g. '15087023444'. Tip: search several advertisers in one run with ' OR ' — e.g. 'Nike OR Adidas'."
          },
          "country": {
            "title": "Country (ISO code)",
            "pattern": "^([A-Za-z]{2}|ALL|all)$",
            "type": "string",
            "description": "Two-letter ISO country code to filter ads (e.g. BR, US, GB, DE, MX). Use 'ALL' for every country. Use the ISO code, not the country name.",
            "default": "BR"
          },
          "adType": {
            "title": "Ad type",
            "enum": [
              "all",
              "political_and_issue_ads"
            ],
            "type": "string",
            "description": "Filter by ad type. 'Political & Issue Ads' also exposes spend and impression ranges.",
            "default": "all"
          },
          "activeStatus": {
            "title": "Status filter",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "Return currently-running ads, historical (inactive) ads, or both.",
            "default": "active"
          },
          "startDateFrom": {
            "title": "Ads started on or after (YYYY-MM-DD)",
            "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$",
            "type": "string",
            "description": "Keep only ads whose start date is on or after this date, e.g. '2026-01-01'. Leave empty for no lower bound. Ads whose start date Meta does not expose are always kept."
          },
          "startDateTo": {
            "title": "Ads started on or before (YYYY-MM-DD)",
            "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$",
            "type": "string",
            "description": "Keep only ads whose start date is on or before this date, e.g. '2026-06-30'. Leave empty for no upper bound."
          },
          "maxAds": {
            "title": "Maximum ads",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Maximum number of ads to extract (1–500). Billed per valid ad extracted according to the Apify Store pricing panel. Free-tier runs are capped at 3 ads. Start with 20 to validate your query before scaling.",
            "default": 50
          },
          "includeAiAnalysis": {
            "title": "Include AI analysis",
            "type": "boolean",
            "description": "Use Google Gemini to summarize ad strategy, dominant format, key messages and competitive insights. Requires a GEMINI_API_KEY in the actor's environment variables.",
            "default": false
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Proxy settings. Start WITHOUT proxy to minimize cost — Meta Ad Library is public and usually loads over datacenter. Only enable a RESIDENTIAL proxy if a run is blocked or returns zero 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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}