{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ads Library Scraper",
    "description": "Scrape Facebook & Instagram ads from the Meta Ad Library: keyword, exact phrase, Page or Ads Library URL; sort by most recent. Get creatives, copy, links and media, plus optional EU reach, age/gender and targeting details. No login or API token.",
    "version": "0.1",
    "x-build-id": "hPP7O5ehukzwvkSLr"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/automation-lab~facebook-ads-library/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-automation-lab-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/automation-lab~facebook-ads-library/runs": {
      "post": {
        "operationId": "runs-sync-automation-lab-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/automation-lab~facebook-ads-library/run-sync": {
      "post": {
        "operationId": "run-sync-automation-lab-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",
        "properties": {
          "searchQueries": {
            "title": "🔍 Search keywords",
            "maxItems": 20,
            "type": "array",
            "description": "Enter keywords to search for in the Ad Library (e.g. \"shopify\", \"running shoes\"). Each keyword runs a separate search. Safety cap: up to 20 total search/page/Ads Library URL tasks per run.",
            "items": {
              "type": "string"
            }
          },
          "pageUrls": {
            "title": "📄 Advertiser Page or Instagram URLs",
            "maxItems": 20,
            "type": "array",
            "description": "Enter Facebook Page URLs to scrape ads from specific advertisers (e.g. \"https://www.facebook.com/shopify\"), or the advertiser's Instagram profile (e.g. \"https://www.instagram.com/shopify\"). Each Page is resolved to its Ads Library Page ID, so only that advertiser's ads are returned. An Instagram profile counts only when an Ads Library advertiser links exactly that username. Pages we can't identify with certainty, and other URLs, are skipped and not charged. For a skipped Page, paste its Ads Library URL (with view_all_page_id) instead. Safety cap: up to 20 total search/page/Ads Library URL tasks per run.",
            "items": {
              "type": "string"
            }
          },
          "adsLibraryUrls": {
            "title": "🔗 Ads Library result URLs",
            "maxItems": 20,
            "type": "array",
            "description": "Paste Facebook Ads Library results URLs copied from facebook.com/ads/library/. Embedded URL filters (keyword, page ID, country, status, media type, search type, and supported ad type) are used for this input; unsupported URL parameters such as date, language, or platform filters are ignored with a warning. Safety cap: up to 20 total search/page/Ads Library URL tasks per run.",
            "items": {
              "type": "string"
            }
          },
          "country": {
            "title": "🌍 Country",
            "type": "string",
            "description": "ISO country code to search in. Use \"ALL\" for all countries.",
            "default": "US"
          },
          "activeStatus": {
            "title": "Status filter",
            "enum": [
              "all",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Filter by ad status.",
            "default": "all"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "all",
              "image_and_meme",
              "video"
            ],
            "type": "string",
            "description": "Filter by ad media type.",
            "default": "all"
          },
          "onlyAdsNewerThan": {
            "title": "Active on or after",
            "type": "string",
            "description": "Optional inclusive lower bound for the ad activity interval. Use YYYY-MM-DD or a positive relative duration such as \"30 days\". An ad matches when its start/end activity interval overlaps the requested date window.",
            "default": ""
          },
          "onlyAdsOlderThan": {
            "title": "Active on or before",
            "type": "string",
            "description": "Optional inclusive upper bound for the ad activity interval. Use YYYY-MM-DD or a positive relative duration such as \"90 days\". Active ads with no end date are handled as still active.",
            "default": ""
          },
          "searchType": {
            "title": "Keyword match",
            "enum": [
              "keyword_unordered",
              "keyword_exact_phrase"
            ],
            "type": "string",
            "description": "How keywords match ad text. \"Any words\" is Facebook's default; \"Exact phrase\" sends Facebook's exact-phrase search; Facebook may match the phrase in an ad variant, media or text that is not exported, so not every row visibly contains it. Applies to search keywords only.",
            "default": "keyword_unordered"
          },
          "sortBy": {
            "title": "Sort by",
            "enum": [
              "impressions",
              "recent"
            ],
            "type": "string",
            "description": "\"Most impressions\" is Facebook's default order. \"Most recent\" uses Facebook's \"Most recent\" ranking, which favours recently started ads (useful for monitoring new creatives) but groups by month and relevance, so it is not strict start-date order. A sort set in a pasted Ads Library URL is kept.",
            "default": "impressions"
          },
          "maxAds": {
            "title": "⚙️ Max ads",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Maximum number of ads to extract per search query, page URL, or Ads Library URL. The scraper scrolls to load more results automatically. Safety cap: 500 per search/page task; split very large exports into smaller runs for clearer progress and lower abort risk.",
            "default": 100
          },
          "includeAdDetails": {
            "title": "Include ad details (EU reach, targeting, payer)",
            "type": "boolean",
            "description": "Adds an <code>adDetails</code> object to each ad with what Meta's \"See ad details\" panel shows: EU total reach, reach by country/age/gender, targeted locations, age and gender, payer and beneficiary, and advertiser Instagram followers and verification. EU reach and targeting exist for ads delivered in the EU; other ads still get advertiser info. Same price per ad. Adds roughly 1 second per 6 ads to the run.",
            "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
                  },
                  "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}