{
  "openapi": "3.0.1",
  "info": {
    "title": "Meta Ad Library API - Facebook & Instagram Ads Scraper",
    "description": "Collect public Facebook and Instagram ads from the Meta Ad Library by keyword, advertiser Page or brand name. Filter by country, status, category, format, platform and date, with structured creative and timing fields.",
    "version": "0.1",
    "x-build-id": "FFoZ1JdLDbA5kLzbG"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/thenetaji~meta-ad-library-api-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-thenetaji-meta-ad-library-api-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/thenetaji~meta-ad-library-api-scraper/runs": {
      "post": {
        "operationId": "runs-sync-thenetaji-meta-ad-library-api-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/thenetaji~meta-ad-library-api-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-thenetaji-meta-ad-library-api-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",
        "required": [
          "scraperType"
        ],
        "properties": {
          "scraperType": {
            "title": "What do you want to do?",
            "enum": [
              "search",
              "page",
              "searchPages"
            ],
            "type": "string",
            "description": "Choose the workflow for this run. Each section below says which workflows read it.",
            "default": "search"
          },
          "startUrl": {
            "title": "Start URL",
            "type": "string",
            "description": "Paste a Facebook Meta Ad Library search or page URL. Its supported filters are resolved automatically, and anything you set below overrides the URL."
          },
          "q": {
            "title": "Search Query / Company Name",
            "type": "string",
            "description": "For ad search, enter a keyword or phrase. For advertiser lookup, enter a brand or company name, such as Nike."
          },
          "page_id": {
            "title": "Facebook Page ID",
            "type": "string",
            "description": "Numeric ID of the advertiser's Facebook Page whose ads you want. Don't know it? Use the \"Find advertiser page\" mode to look it up by brand name."
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code to target, e.g. US, IN, GB. Leave blank to use US."
          },
          "date_min": {
            "title": "Start Date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Only include ads active on or after this date (YYYY-MM-DD)."
          },
          "date_max": {
            "title": "End Date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string",
            "description": "Only include ads active on or before this date (YYYY-MM-DD)."
          },
          "active_status": {
            "title": "Ad Status",
            "enum": [
              "all",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Return all ads, or only currently active or inactive ones. Leave blank to return all ads."
          },
          "ad_type": {
            "title": "Ad Category",
            "enum": [
              "ALL",
              "POLITICAL_AND_ISSUE_ADS",
              "HOUSING_ADS",
              "EMPLOYMENT_ADS",
              "CREDIT_ADS"
            ],
            "type": "string",
            "description": "Limit results to a specific ad category, such as political and issue ads. Leave blank to include all categories."
          },
          "media_type": {
            "title": "Creative Format",
            "enum": [
              "all",
              "image",
              "video",
              "meme"
            ],
            "type": "string",
            "description": "Limit results to a creative format: images, videos, or memes. Leave blank to include all formats."
          },
          "search_type": {
            "title": "Keyword Match",
            "enum": [
              "keyword_unordered",
              "keyword_exact_phrase"
            ],
            "type": "string",
            "description": "How to match your search query: keywords in any order, or the exact phrase."
          },
          "publisher_platforms": {
            "title": "Platforms",
            "type": "array",
            "description": "Only include ads shown on the selected Meta platforms.",
            "items": {
              "type": "string",
              "enum": [
                "FACEBOOK",
                "INSTAGRAM",
                "AUDIENCE_NETWORK",
                "MESSENGER"
              ],
              "enumTitles": [
                "Facebook",
                "Instagram",
                "Audience Network",
                "Messenger"
              ]
            }
          },
          "content_languages": {
            "title": "Ad Languages",
            "type": "string",
            "description": "Comma-separated ISO 639-1 language codes to include, e.g. en,hi,es."
          },
          "page_ids": {
            "title": "Filter by Page IDs",
            "type": "string",
            "description": "Comma-separated Facebook Page IDs to restrict results to specific advertisers."
          },
          "is_targeted_country": {
            "title": "Targeted Country Only",
            "type": "boolean",
            "description": "Only show ads that specifically target the selected country. Leave blank or off to include all ads."
          },
          "potential_reach_min": {
            "title": "Min Audience Size",
            "type": "integer",
            "description": "Only include ads with at least this estimated audience size."
          },
          "potential_reach_max": {
            "title": "Max Audience Size",
            "type": "integer",
            "description": "Only include ads with at most this estimated audience size."
          },
          "sort_mode": {
            "title": "Sort By",
            "enum": [
              "total_impressions"
            ],
            "type": "string",
            "description": "Order results by a metric. Leave empty for the default order."
          },
          "sort_direction": {
            "title": "Sort Direction",
            "enum": [
              "desc"
            ],
            "type": "string",
            "description": "Direction to sort in when Sort By is set."
          },
          "maxItems": {
            "title": "Max Results",
            "minimum": 0,
            "type": "integer",
            "description": "Maximum number of results to return. Set 0 for no limit.",
            "default": 50
          },
          "enrichAdDetails": {
            "title": "Include full ad details",
            "type": "boolean",
            "description": "Include the available full detail record for every returned ad.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}