{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Ads Scraper",
    "description": "Scrape ads from the Meta (Facebook) Ad Library via the internal GraphQL endpoint.",
    "version": "0.0",
    "x-build-id": "aHRu0PUaLfmNq2X95"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/techbellys~facebook-ads-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-techbellys-facebook-ads-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/techbellys~facebook-ads-scraper/runs": {
      "post": {
        "operationId": "runs-sync-techbellys-facebook-ads-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/techbellys~facebook-ads-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-techbellys-facebook-ads-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": {
          "keywords": {
            "title": "Search keywords",
            "type": "array",
            "description": "Plain search terms, e.g. \"online mba course\". The full Meta Ad Library URL is generated automatically from these plus the country / sorting / media type fields below. Use this instead of Start URLs when your backend only has a keyword.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "keyword": {
            "title": "Search keyword (single)",
            "type": "string",
            "description": "Convenience alias for a single keyword. Merged with Search keywords.",
            "default": ""
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "Two-letter country code used when building the Ad Library URL from keywords.",
            "default": "IN"
          },
          "searchType": {
            "title": "Search type",
            "enum": [
              "keyword_unordered",
              "keyword_exact_phrase"
            ],
            "type": "string",
            "description": "How the keyword is matched. Exact phrase automatically wraps the keyword in quotes.",
            "default": "keyword_unordered"
          },
          "adType": {
            "title": "Ad type",
            "enum": [
              "all",
              "political_and_issue_ads",
              "housing_ads",
              "employment_ads",
              "credit_ads"
            ],
            "type": "string",
            "description": "Maps to ad_type in the Ad Library URL. Leave as All ads for normal commercial ads.",
            "default": "all"
          },
          "mediaType": {
            "title": "Media type",
            "enum": [
              "all",
              "image",
              "meme",
              "image_and_meme",
              "video",
              "none"
            ],
            "type": "string",
            "description": "Maps to media_type in the Ad Library URL, e.g. Video to only collect video creatives.",
            "default": "all"
          },
          "isTargetedCountry": {
            "title": "Only ads targeted at this country",
            "type": "boolean",
            "description": "Maps to is_targeted_country in the Ad Library URL.",
            "default": false
          },
          "sortDirection": {
            "title": "Sort direction",
            "enum": [
              "desc",
              "asc"
            ],
            "type": "string",
            "description": "Maps to sort_data[direction] in the Ad Library URL.",
            "default": "desc"
          },
          "startUrls": {
            "title": "🔗 Meta Ad Library URL or Facebook Page URL",
            "type": "array",
            "description": "Add a Facebook Page URL, a brand URL from Meta Ad Library, or a Meta Ad Library search URL. You can add multiple URLs using the Bulk edit option.",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "resultsLimit": {
            "title": "💯 Results limit per URL",
            "minimum": 1,
            "type": "integer",
            "description": "Maximum ads to scrape per input URL. Leave empty to scrape as many as possible.",
            "default": 10
          },
          "activeStatus": {
            "title": "🖱️ Active status (if not specified within the Meta Ad Library URL)",
            "enum": [
              "",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Filter ads by whether they are currently running.",
            "default": ""
          },
          "sorting": {
            "title": "🗂️ Sorting (if not set in the Meta Ad Library URL)",
            "enum": [
              "",
              "total_impressions",
              "relevancy_monthly_grouped"
            ],
            "type": "string",
            "description": "Sort order for scraped ads.",
            "default": ""
          },
          "isDetailsPerAd": {
            "title": "Include extra ad details (reach & spend data, basic Instagram data)",
            "type": "boolean",
            "description": "Adds an ad_details object with advertiser page info.",
            "default": false
          },
          "includeAboutPage": {
            "title": "Include page About details",
            "type": "boolean",
            "description": "Extracts About tab details (business address, admin locations, page history).",
            "default": false
          },
          "onlyTotal": {
            "title": "Get only the total ad count per page",
            "type": "boolean",
            "description": "Returns only the total number of ads per page instead of scraping individual ads.",
            "default": false
          },
          "onlyAdsNewerThan": {
            "title": "Scrape ads newer than",
            "type": "string",
            "description": "Only scrape ads with a start date newer than this date (e.g. 2025-01-01)."
          },
          "onlyAdsOlderThan": {
            "title": "Scrape ads older than",
            "type": "string",
            "description": "Only scrape ads with a start date older than this date (e.g. 2025-01-01)."
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Residential proxies are strongly recommended; Facebook blocks datacenter IPs.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}