{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ad Library Scraper — Meta Ad Library API",
    "description": "Track what your competitors advertise on Facebook and Instagram. Scrapes Meta's public Ad Library into clean JSON — ad copy, every creative image and video, CTA, destination URL and run dates. No Meta API token, no login. Scheduled runs bill only what is new or changed.",
    "version": "1.0",
    "x-build-id": "Nk9fDy6s9L44jDx6l"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/sukhdipp~meta-ad-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-sukhdipp-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/sukhdipp~meta-ad-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-sukhdipp-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/sukhdipp~meta-ad-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-sukhdipp-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",
        "properties": {
          "searchTerms": {
            "title": "Search terms",
            "type": "array",
            "description": "Keywords to search the Ad Library for, e.g. \"protein powder\". One query per term. Use this OR pageIds OR adLibraryUrls — at least one is required.",
            "items": {
              "type": "string"
            }
          },
          "pageIds": {
            "title": "Facebook Page IDs",
            "type": "array",
            "description": "Numeric Page IDs to pull every ad for — the way to track a specific competitor. Find the ID in the Ad Library URL as view_all_page_id=...",
            "items": {
              "type": "string"
            }
          },
          "advertiserDomains": {
            "title": "Advertiser domains (finds the right Page)",
            "type": "array",
            "description": "Give a website, e.g. nike.com, and get that brand's ads without the same-name impostors. Searching a brand by name returns every unrelated Page sharing it; this searches the name and then keeps only ads whose destination is that domain. Subdomains included.",
            "items": {
              "type": "string"
            }
          },
          "adLibraryUrls": {
            "title": "Ad Library URLs",
            "type": "array",
            "description": "Paste Ad Library URLs straight from the browser. Filters in the URL (country, active status, media type, page) are read and applied.",
            "items": {
              "type": "string"
            }
          },
          "countries": {
            "title": "Countries",
            "type": "array",
            "description": "ISO-3166 alpha-2 codes (US, DE, IT), or ALL for every country. Note: outside the EU only political and issue ads carry spend and impression figures — see the README FAQ.",
            "default": [
              "ALL"
            ],
            "items": {
              "type": "string"
            }
          },
          "activeStatus": {
            "title": "Active status",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "Only ads currently running, only ones that stopped, or both.",
            "default": "active"
          },
          "adType": {
            "title": "Ad type",
            "enum": [
              "all",
              "political"
            ],
            "type": "string",
            "description": "All ads, or only political and issue ads (the ones with spend, impressions and funding data).",
            "default": "all"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "all",
              "image",
              "video",
              "meme"
            ],
            "type": "string",
            "description": "Keep only ads using this media type. Meta applies this server-side, so it also reduces how much is fetched.",
            "default": "all"
          },
          "maxAds": {
            "title": "Max ads (spend cap)",
            "minimum": 1,
            "maximum": 200000,
            "type": "integer",
            "description": "Hard ceiling on billable ads for this run. The run stops cleanly at this number and says so in the status message — it never fails. This is your spend control: at $0.60 per 1,000 ads, 1,000 ads costs $0.60.",
            "default": 1000
          },
          "maxCostUsd": {
            "title": "Max cost (USD)",
            "minimum": 1,
            "type": "integer",
            "description": "Optional second ceiling, in dollars. Whichever limit is reached first stops the run. Leave empty to rely on Max ads alone."
          },
          "maxPagesPerQuery": {
            "title": "Max pages per query",
            "minimum": 1,
            "maximum": 5000,
            "type": "integer",
            "description": "Safety valve against a query that paginates forever. 10 ads per page.",
            "default": 200
          },
          "monitorMode": {
            "title": "Monitor mode",
            "enum": [
              "off",
              "annotate",
              "changes-only"
            ],
            "type": "string",
            "description": "For scheduled runs. 'Annotate' returns every ad tagged new/changed/unchanged. 'Changes only' returns just what is new or changed — and you are only billed for those. Unchanged and removed ads are always free.",
            "default": "off"
          },
          "monitorId": {
            "title": "Monitor ID",
            "type": "string",
            "description": "Names the memory this schedule diffs against. Use a different ID per schedule so two schedules never diff each other's ads.",
            "default": "default"
          },
          "emitRemoved": {
            "title": "Report removed ads",
            "type": "boolean",
            "description": "Emit a free record when an ad that was running has stopped. Only queries that actually succeeded can report removals, so a failed run never fakes a wave of removals.",
            "default": true
          },
          "persistMedia": {
            "title": "Save media to key-value store",
            "type": "boolean",
            "description": "Meta's CDN links expire within days. Turn this on to download each image and video into this run's key-value store and rewrite the URLs to permanent ones. Costs extra bandwidth; off by default.",
            "default": false
          },
          "includeCards": {
            "title": "Include carousel cards",
            "type": "boolean",
            "description": "Keep the per-card breakdown of carousel ads. Media from cards is always collected either way.",
            "default": true
          },
          "publisherPlatforms": {
            "title": "Platforms",
            "type": "array",
            "description": "Keep only ads shown on these platforms: FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS. Filtered ads are never billed.",
            "items": {
              "type": "string"
            }
          },
          "minDaysRunning": {
            "title": "Minimum days running",
            "minimum": 1,
            "type": "integer",
            "description": "Keep only ads live at least this long. Long-running ads are the standard proxy for a winning creative — but see the README: it is a proxy, not a performance metric."
          },
          "maxDaysRunning": {
            "title": "Maximum days running",
            "minimum": 1,
            "type": "integer",
            "description": "Keep only ads live at most this long — useful for spotting fresh creative launches."
          },
          "startedAfter": {
            "title": "Started after",
            "type": "string",
            "description": "Keep ads that started on or after this date. Accepts YYYY-MM-DD or a relative form like \"30 days\"."
          },
          "startedBefore": {
            "title": "Started before",
            "type": "string",
            "description": "Keep ads that started on or before this date. Accepts YYYY-MM-DD or \"6 months\"."
          },
          "excludeDisplayFormats": {
            "title": "Exclude ad formats",
            "type": "array",
            "description": "Drop these display formats, e.g. DCO — the format most often returning thin or empty creatives.",
            "items": {
              "type": "string"
            }
          },
          "requireMedia": {
            "title": "Only ads with creatives",
            "type": "boolean",
            "description": "Drop ads with no image and no video. You are not billed for what is dropped.",
            "default": false
          },
          "minVariantCount": {
            "title": "Minimum variant count",
            "minimum": 2,
            "type": "integer",
            "description": "Keep only creatives Meta grouped into at least this many near-identical copies — the closest public signal that a creative is being scaled."
          },
          "maxAdsPerPage": {
            "title": "Max ads per advertiser",
            "minimum": 1,
            "type": "integer",
            "description": "Keep at most this many ads per Facebook Page. A keyword search usually returns the same few advertisers hundreds of times; set 1 to see one ad per advertiser. Applied before billing, so it cuts the cost too."
          },
          "bodyContains": {
            "title": "Ad copy contains",
            "type": "array",
            "description": "Keep ads whose copy contains any of these words. Searches every body, headline and card, not just the main text.",
            "items": {
              "type": "string"
            }
          },
          "bodyExcludes": {
            "title": "Ad copy excludes",
            "type": "array",
            "description": "Drop ads whose copy contains any of these words.",
            "items": {
              "type": "string"
            }
          },
          "linkDomains": {
            "title": "Destination domains",
            "type": "array",
            "description": "Keep only ads pointing at these domains, e.g. nike.com (subdomains included). Also the reliable way to tell two identically-named Pages apart.",
            "items": {
              "type": "string"
            }
          },
          "resumeFromCheckpoint": {
            "title": "Resume an interrupted run",
            "type": "boolean",
            "description": "If a previous run was cut short — a crash, a proxy failure, or an Apify platform migration — continue from the exact page it reached instead of starting over. Ads already collected are not fetched or billed again. Turn off to force a clean run from the top.",
            "default": true
          },
          "webhookUrl": {
            "title": "Webhook URL (push the changes)",
            "type": "string",
            "description": "HTTPS endpoint that receives a POST when the run finishes: the new, changed, scaling and stopped ads, plus a run-status block saying whether the run was complete enough to trust them. A failed webhook never fails the run."
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Strongly recommended. Meta blocks a single IP after roughly 47 requests (about 470 ads) and in our tests that block lasted hours. Residential proxies with automatic session rotation are what make large runs work.",
            "default": {
              "useApifyProxy": true,
              "apifyProxyGroups": [
                "RESIDENTIAL"
              ]
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}