{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ads Library Scraper Pro: Meta Ads by Keyword/Page",
    "description": "Scrape ads from Meta's public Ad Library by keyword, Page ID or ready-made URL. Full ad text, images & videos, CTA, links, platforms, dates, copies count, spend & impressions. Duplicates and failures never charged. $0.002 per ad.",
    "version": "1.0",
    "x-build-id": "ultekWuOmpOfeuRPz"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/muarafa~facebook-ads-library-pro/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-muarafa-facebook-ads-library-pro",
        "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/muarafa~facebook-ads-library-pro/runs": {
      "post": {
        "operationId": "runs-sync-muarafa-facebook-ads-library-pro",
        "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/muarafa~facebook-ads-library-pro/run-sync": {
      "post": {
        "operationId": "run-sync-muarafa-facebook-ads-library-pro",
        "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 keywords",
            "type": "array",
            "description": "Keywords or brand names to search in the Meta Ad Library, e.g. <code>nike</code>, <code>shopify</code>. One search per keyword. Provide at least one of <b>Search keywords</b>, <b>Page IDs</b> or <b>Ad Library URLs</b>.",
            "items": {
              "type": "string"
            }
          },
          "pageIds": {
            "title": "Facebook Page IDs",
            "type": "array",
            "description": "Numeric Facebook Page IDs to get all ads of one advertiser (e.g. Nike = <code>15087023444</code>). You can find the ID in the Ad Library URL as <code>view_all_page_id=…</code>.",
            "items": {
              "type": "string"
            }
          },
          "urls": {
            "title": "Ad Library URLs",
            "type": "array",
            "description": "Ready-made Ad Library links (<code>https://www.facebook.com/ads/library/?…</code>) with any filters you already set in the browser. Their own filters are used as they are.",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "Country where the ads were shown, as a 2-letter ISO code (<code>US</code>, <code>GB</code>, <code>DE</code>, <code>EG</code>…) or <code>ALL</code> for every country. Applies to keywords and Page IDs.",
            "default": "ALL"
          },
          "adType": {
            "title": "Ad type",
            "enum": [
              "all",
              "political_and_issue"
            ],
            "type": "string",
            "description": "All ads, or only political and issue ads (these also include spend and impressions ranges).",
            "default": "all"
          },
          "activeStatus": {
            "title": "Ad status",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "Only ads that are running now, only ads that stopped, or both.",
            "default": "active"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "all",
              "image",
              "video"
            ],
            "type": "string",
            "description": "Restrict to ads with images or with videos.",
            "default": "all"
          },
          "startDate": {
            "title": "Started on or after",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Only ads that started running on or after this date (<code>YYYY-MM-DD</code>)."
          },
          "endDate": {
            "title": "Started on or before",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Only ads that started running on or before this date (<code>YYYY-MM-DD</code>)."
          },
          "language": {
            "title": "Ad language",
            "type": "string",
            "description": "Optional language code of the ad content (<code>en</code>, <code>es</code>, <code>ar</code>, <code>fr</code>…). Leave empty for all languages."
          },
          "maxAdsPerQuery": {
            "title": "Max ads per keyword / page / URL",
            "minimum": 1,
            "maximum": 20000,
            "type": "integer",
            "description": "Stop each query after this many new ads.",
            "default": 100
          },
          "maxTotalAds": {
            "title": "Max ads in total",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Hard cap for the whole run. You are charged only for ads actually delivered, never for duplicates or failures.",
            "default": 1000
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Apify Proxy is recommended. Datacenter proxies are tried by default; pick the <code>RESIDENTIAL</code> group if Meta refuses requests from your IPs.",
            "default": {
              "useApifyProxy": true
            }
          },
          "maxRetries": {
            "title": "Max retries per query",
            "minimum": 0,
            "maximum": 10,
            "type": "integer",
            "description": "When a response comes back empty or refused, the scraper retries with a brand-new browser session and proxy IP up to this many times.",
            "default": 4
          },
          "accessToken": {
            "title": "Official API access token (optional fallback)",
            "type": "string",
            "description": "Only used if the public Ad Library page is completely unavailable. Create a token for Meta's official <a href=\"https://www.facebook.com/ads/library/api/\">Ad Library API</a>; the Actor then fetches the same query from the API (fewer fields: no media files or CTA)."
          }
        }
      },
      "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}