{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ads Library",
    "description": "Facebook Ads Library scraper, Facebook Ad Library scraper and Meta Ad Library API: Facebook and Instagram ads by keyword, advertiser or Ad Library URL; one row per ad with text, media, landing page, dates, advertiser and EU reach. $0.45 per 1,000 ads on Starter, 11x cheaper than the most-used rival.",
    "version": "0.8",
    "x-build-id": "MXVBHi8WjcLuTfFNz"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/deepmine~meta-ad-library/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-deepmine-meta-ad-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/deepmine~meta-ad-library/runs": {
      "post": {
        "operationId": "runs-sync-deepmine-meta-ad-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/deepmine~meta-ad-library/run-sync": {
      "post": {
        "operationId": "run-sync-deepmine-meta-ad-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 terms",
            "type": "array",
            "description": "Keywords to search ads for, as you'd type them in the Ad Library search box. Give at least one of searchQueries, advertisers, startUrls or adIds.",
            "items": {
              "type": "string"
            }
          },
          "advertisers": {
            "title": "🏢 Advertisers",
            "type": "array",
            "description": "Accepts Facebook page URLs, usernames, page IDs, advertiser names, their Ad Library URLs, and Instagram profile URLs or @handles. Instagram results are matched to their advertising page.",
            "items": {
              "type": "string"
            }
          },
          "country": {
            "title": "🌍 Country",
            "type": "string",
            "description": "Two-letter country code where the ads ran (US, GB, DE, ...), or ALL for every country (left out = ALL).",
            "default": "ALL"
          },
          "maxAdsPerQuery": {
            "title": "💯 Max ads per search",
            "minimum": 0,
            "type": "integer",
            "description": "Stop each search, advertiser or URL after this many ads. Use 0 for no per-search limit. When Meta limits pagination, the Actor scans smaller date ranges, which can change the overall order. Run spending and time limits still apply.",
            "default": 200
          },
          "includeAdDetails": {
            "title": "📋 Include ad details",
            "type": "boolean",
            "description": "Also fetch each ad's details: the advertiser's verification and Instagram account and followers and, for ads shown in the EU or UK, the reach, reach by country, targeted ages and gender, plus the payer and beneficiary (Meta's full details, with reach by age and gender, are in ad_details). Details are included in the ad price at no extra cost; each ad needs one more request, so runs are slower.",
            "default": false
          },
          "enrichStores": {
            "title": "Enrich advertiser landing pages",
            "type": "boolean",
            "description": "Add the store platform, currency, tracking tools and public contact details when we find them on an ad's landing page. We check each domain once per run. Ads are still returned when a page is unavailable.",
            "default": false
          },
          "onlyNewAds": {
            "title": "Only new ads",
            "type": "boolean",
            "description": "For the same search and filters, skip ads already delivered by this monitor. Runs use the newest ads first. The first run has no history.",
            "default": false
          },
          "includeAboutPage": {
            "title": "Include advertiser page info",
            "type": "boolean",
            "description": "Add the public page transparency and profile information Meta returns, including linked Instagram details when available.",
            "default": false
          },
          "includeTotalActiveAds": {
            "title": "Include advertiser active ad count",
            "type": "boolean",
            "description": "Add Meta’s total active ad count for each advertiser in the selected countries, independent of other search filters.",
            "default": false
          },
          "onlyTotal": {
            "title": "Only retrieve counts",
            "type": "boolean",
            "description": "Save Meta’s counts to the run summary (OUTPUT), without writing or charging for ad rows. Capped totals appear as 50000 with isCapped set to true.",
            "default": false
          },
          "startUrls": {
            "title": "Ad Library URLs",
            "type": "array",
            "description": "Ad Library search or ad links, Facebook page URLs, and Instagram profile URLs. Ad Library search links use the filters in the URL.",
            "items": {
              "type": "string"
            }
          },
          "adIds": {
            "title": "Ad Library IDs",
            "type": "array",
            "description": "Look up individual ads by Library ID or by Ad Library links with ?id=.",
            "items": {
              "type": "string"
            }
          },
          "sortBy": {
            "title": "↕️ Sort ads by",
            "enum": [
              "impressions",
              "recent"
            ],
            "type": "string",
            "description": "`impressions` (default): top ads first, the ones with the most impressions, as the Ad Library sorts them; `recent`: most recent first (grouped by the month they started).",
            "default": "impressions"
          },
          "activeStatus": {
            "title": "Ad status",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "`active` (default): only active ads; `inactive`: only ads that stopped; `all`: both.",
            "default": "active"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "all",
              "image",
              "video",
              "meme",
              "image_and_meme",
              "none"
            ],
            "type": "string",
            "description": "Only ads with this kind of media.",
            "default": "all"
          },
          "adType": {
            "title": "Ad category",
            "enum": [
              "all",
              "political_and_issue_ads",
              "housing_ads",
              "employment_ads",
              "credit_ads"
            ],
            "type": "string",
            "description": "All ads, or only one of Meta's special categories: social issues, elections or politics (these carry spend and impressions ranges), housing, employment, or credit and financial products.",
            "default": "all"
          },
          "countries": {
            "title": "Several countries",
            "type": "array",
            "description": "Two-letter country codes (US, GB, DE, ...) to search all at once, instead of the one Country above. Each search covers all of them, and an ad shown in several of them is one row.",
            "items": {
              "type": "string"
            }
          },
          "contentLanguages": {
            "title": "Ad language",
            "type": "array",
            "description": "Only ads in these languages, as two-letter codes (en, es, de, fr, ...). Left empty: every language.",
            "items": {
              "type": "string"
            }
          },
          "publisherPlatforms": {
            "title": "Platforms",
            "type": "array",
            "description": "Only ads shown on any of these platforms. Left empty: every platform.",
            "items": {
              "type": "string",
              "enum": [
                "facebook",
                "instagram",
                "messenger",
                "audience_network",
                "threads",
                "whatsapp"
              ],
              "enumTitles": [
                "Facebook",
                "Instagram",
                "Messenger",
                "Audience Network",
                "Threads",
                "WhatsApp"
              ]
            }
          },
          "exactPhrase": {
            "title": "Exact phrase",
            "type": "boolean",
            "description": "Match the search terms as an exact phrase instead of any order.",
            "default": false
          },
          "dateFrom": {
            "title": "Shown on or after",
            "type": "string",
            "description": "Only ads that were shown on or after this date (YYYY-MM-DD), whatever day they started. This is the Ad Library's own date filter."
          },
          "dateTo": {
            "title": "Shown on or before",
            "type": "string",
            "description": "Only ads that were shown on or before this date (YYYY-MM-DD)."
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Apify Proxy starts with datacenter IPs and falls back to residential if Meta rejects them. You can also enter your own proxy URLs.",
            "default": {
              "useApifyProxy": true
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}