{
  "openapi": "3.0.1",
  "info": {
    "title": "Meta Ads Library Scraper (Optimized for Devs)",
    "description": "Fast batch scrape of public Meta Ad Library ads by page ID or keyword. Clean JSON for developers — no personal user PII.",
    "version": "1.5",
    "x-build-id": "c4qT3daDKv8fj14zS"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/hoang_minh_quan~meta-ads-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-hoang_minh_quan-meta-ads-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/hoang_minh_quan~meta-ads-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-hoang_minh_quan-meta-ads-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/hoang_minh_quan~meta-ads-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-hoang_minh_quan-meta-ads-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": {
          "pageIds": {
            "title": "Facebook Page IDs",
            "type": "array",
            "description": "Batch of Meta/Facebook Page IDs to scrape (e.g. 559929417490965). Preferred for brand monitoring.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "keywords": {
            "title": "Search keywords",
            "type": "array",
            "description": "Keyword searches in Ad Library (unordered). Useful for category / competitor discovery.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "pageId": {
            "title": "Single page ID (legacy)",
            "type": "string",
            "description": "Optional single page ID (same as adding one entry to pageIds)."
          },
          "keyword": {
            "title": "Single keyword (legacy)",
            "type": "string",
            "description": "Optional single keyword (same as adding one entry to keywords)."
          },
          "country": {
            "title": "Ad Library country",
            "type": "string",
            "description": "ISO country code for Ad Library results (US, VN, GB, …).",
            "default": "US"
          },
          "activeStatus": {
            "title": "Active status filter",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "Filter: active | inactive | all",
            "default": "active"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "all",
              "image",
              "video",
              "meme",
              "none"
            ],
            "type": "string",
            "description": "Filter: all | image | video | meme | none",
            "default": "all"
          },
          "maxAdsPerTarget": {
            "title": "Max ads per target",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Cap ads returned for each pageId/keyword (1–200).",
            "default": 50
          },
          "scrollRounds": {
            "title": "Scroll / pagination rounds",
            "minimum": 1,
            "maximum": 30,
            "type": "integer",
            "description": "How many scroll + load-more rounds per target.",
            "default": 8
          },
          "maxAttempts": {
            "title": "Max retry attempts",
            "minimum": 1,
            "maximum": 6,
            "type": "integer",
            "description": "Retries with a fresh residential proxy session.",
            "default": 3
          },
          "concurrency": {
            "title": "Target concurrency",
            "minimum": 1,
            "maximum": 3,
            "type": "integer",
            "description": "How many pageId/keyword targets to scrape in parallel (1–3). Higher = faster but more proxy usage.",
            "default": 1
          },
          "useApifyProxy": {
            "title": "Use Apify residential proxy",
            "type": "boolean",
            "description": "Strongly recommended. Meta blocks most datacenter IPs.",
            "default": true
          },
          "proxyCountry": {
            "title": "Proxy country",
            "type": "string",
            "description": "Residential proxy exit country (ISO 2-letter). Prefer US for Ad Library.",
            "default": "US"
          },
          "failOnTargetError": {
            "title": "Fail entire run if one target fails",
            "type": "boolean",
            "description": "If false (default), failed targets are logged and other targets continue.",
            "default": false
          },
          "enableMonitor": {
            "title": "Enable snapshot monitoring (NEW/CHANGED/STOPPED)",
            "type": "boolean",
            "description": "Compare this run to the previous KVS snapshot and tag ads as new / changed / stopped / winners.",
            "default": true
          },
          "snapshotStoreName": {
            "title": "Snapshot Key-Value Store name",
            "type": "string",
            "description": "Named KVS for durable ad snapshots across scheduled runs.",
            "default": "meta-ads-intel-snap-v1"
          },
          "winnerMinDays": {
            "title": "Winner min longevity (days)",
            "minimum": 1,
            "maximum": 365,
            "type": "integer",
            "description": "Active ads running at least this many days are flagged isWinner.",
            "default": 14
          },
          "webhookUrl": {
            "title": "Webhook URL (Slack/Discord/Zapier)",
            "type": "string",
            "description": "POST JSON alerts when material changes are detected."
          },
          "telegramBotToken": {
            "title": "Telegram bot token",
            "type": "string",
            "description": "Optional Telegram BotFather token for change alerts."
          },
          "telegramChatId": {
            "title": "Telegram chat ID",
            "type": "string",
            "description": "Chat / channel ID that receives Telegram alerts."
          },
          "notifyOnlyOnChanges": {
            "title": "Notify only on material changes",
            "type": "boolean",
            "description": "Skip webhook/Telegram on quiet runs (no NEW/CHANGED/STOPPED).",
            "default": true
          },
          "dryRunNotify": {
            "title": "Dry-run notifications",
            "type": "boolean",
            "description": "Log alert payload without sending webhook/Telegram.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}