{
  "openapi": "3.0.1",
  "info": {
    "title": "Meta Ads Library Scraper & Media Archive — Beta",
    "description": "Search Meta ads by keyword or page ID. Get archived media, ad changes and Instagram followers. 10-day beta offer: no Actor fee; Apify usage applies.",
    "version": "0.1",
    "x-build-id": "jbHKi8gSfHUVb2N2O"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/magenta_courser~meta-ads-library-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-magenta_courser-meta-ads-library-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/magenta_courser~meta-ads-library-scraper/runs": {
      "post": {
        "operationId": "runs-sync-magenta_courser-meta-ads-library-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/magenta_courser~meta-ads-library-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-magenta_courser-meta-ads-library-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": {
          "keyword": {
            "title": "Keyword or domain",
            "type": "string",
            "description": "Search public ad text. Provide keyword OR pageId. A domain is sent as a search term, not an exact landing-domain filter."
          },
          "pageId": {
            "title": "Facebook page ID",
            "type": "string",
            "description": "Numeric Facebook page ID. Provide this OR keyword."
          },
          "country": {
            "title": "Country",
            "type": "string",
            "description": "Two-letter country code (US, KR, GB, DE) or ALL. Meta only retains some inactive commercial ads in supported regions.",
            "default": "ALL"
          },
          "activeStatus": {
            "title": "Ad status",
            "enum": [
              "all",
              "active",
              "inactive"
            ],
            "type": "string",
            "description": "Search filter. Historical status checks may additionally report ads that have since stopped.",
            "default": "all"
          },
          "maxAds": {
            "title": "Maximum search ads",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Maximum unique search results. Up to maxStatusChecks previous ads can be emitted additionally to confirm status changes.",
            "default": 50
          },
          "archiveMedia": {
            "title": "Store creative media",
            "type": "boolean",
            "description": "Download original/resized images, HD/SD videos, previews and card media to a named KV store. URLs do not expire while records/account are retained; ongoing storage charges apply.",
            "default": true
          },
          "includeInstagramFollowers": {
            "title": "Instagram follower counts",
            "type": "boolean",
            "description": "One public advertiser detail request per page. Missing or failed counts are null, never zero.",
            "default": true
          },
          "trackChanges": {
            "title": "Compare with previous runs",
            "type": "boolean",
            "description": "Maintain Actor-specific history. Same keyword/page/country/status/namespace uses the same baseline. Missing search rows never prove deactivation.",
            "default": true
          },
          "historyNamespace": {
            "title": "History namespace",
            "pattern": "^[a-zA-Z0-9_-]{1,64}$",
            "type": "string",
            "description": "Use a different name for independent monitoring histories.",
            "default": "default"
          },
          "maxStatusChecks": {
            "title": "Maximum previous-ad status checks",
            "minimum": 0,
            "maximum": 100,
            "type": "integer",
            "description": "Recheck missing previously active ads by ID. Extra confirmed observations may exceed maxAds.",
            "default": 10
          },
          "maxFileSizeMb": {
            "title": "Maximum media file MiB",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "Larger files are reported as failed, not falsely archived.",
            "default": 20
          },
          "maxTotalMediaMb": {
            "title": "Maximum downloaded media MiB",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Shared per-run download budget; skipped variants remain visible in the manifest.",
            "default": 100
          },
          "maxRequests": {
            "title": "Maximum HTTP requests",
            "minimum": 2,
            "maximum": 3000,
            "type": "integer",
            "description": "Shared cap across source operations, recovered sessions and media downloads. Browser assets are capped separately by maxBrowserRequests.",
            "default": 300
          },
          "maxRunSeconds": {
            "title": "Source request time budget",
            "minimum": 30,
            "maximum": 480,
            "type": "integer",
            "description": "Stop starting new source requests after this budget. Configure Actor timeout above this plus 60 seconds.",
            "default": 240
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "US Apify residential proxy for public search/details (verified in a small run). Media CDN downloads use a direct connection to control transfer cost.",
            "default": {
              "useApifyProxy": true,
              "apifyProxyGroups": [
                "RESIDENTIAL"
              ],
              "apifyProxyCountry": "US"
            }
          },
          "mediaType": {
            "title": "Creative type",
            "enum": [
              "all",
              "image",
              "video"
            ],
            "type": "string",
            "description": "Optional source media filter. Each type uses a separate comparison history.",
            "default": "all"
          },
          "pageSize": {
            "title": "Search groups per page",
            "minimum": 1,
            "maximum": 30,
            "type": "integer",
            "description": "Number of source result groups per request. A group can contain multiple ads. This does not change the comparison history scope.",
            "default": 30
          },
          "requestDelayMs": {
            "title": "Minimum request interval (ms)",
            "minimum": 1000,
            "maximum": 10000,
            "type": "integer",
            "description": "Minimum spacing between source operations. Recovery waits are separate and longer. All sessions share the request/time budget.",
            "default": 2000
          },
          "sourceMode": {
            "title": "Collection mode",
            "enum": [
              "http",
              "auto",
              "browser"
            ],
            "type": "string",
            "description": "HTTP uses its selected client and bounded session recovery. Auto can use browser rendering for session/network failures. Plain HTTP source rejection recovery stays on HTTP; login and verification challenges stop.",
            "default": "http"
          },
          "httpBootstrapMode": {
            "title": "HTTP initialization page",
            "enum": [
              "home",
              "library"
            ],
            "type": "string",
            "description": "Advanced comparison option. Library mode reads the initial public results before pagination; home preserves the previously validated HTTP path.",
            "default": "home"
          },
          "maxRecoveries": {
            "title": "Maximum recovery attempts",
            "minimum": 0,
            "maximum": 2,
            "type": "integer",
            "description": "At most two recovery attempts (three sessions total), shared across search and advertiser details. Budget/time limits still apply.",
            "default": 2
          },
          "recoveryDelayMs": {
            "title": "Recovery wait (ms)",
            "minimum": 10000,
            "maximum": 60000,
            "type": "integer",
            "description": "Initial recovery wait; doubles on the second recovery. A longer Retry-After is respected. No attempt starts if the wait exceeds the remaining time budget.",
            "default": 20000
          },
          "maxBrowserRequests": {
            "title": "Maximum browser network requests",
            "minimum": 20,
            "maximum": 300,
            "type": "integer",
            "description": "Additional cap for page assets and automatic browser requests. Images, fonts and video loads are blocked; requested creative downloads are handled separately.",
            "default": 160
          },
          "httpTransport": {
            "title": "HTTP client",
            "enum": [
              "impit",
              "got"
            ],
            "type": "string",
            "description": "HTTP transport for public search/details. Browser mode is separate. Legacy Got is retained for bounded comparisons.",
            "default": "impit"
          },
          "recoverSourceRejections": {
            "title": "Recover temporary HTTP rejections",
            "type": "boolean",
            "description": "After waiting, allow a fresh HTTP proxy/session for a plain 403 or rate-limit response, within maxRecoveries. Honor Retry-After. Login, CAPTCHA, verification challenges and redirects always stop.",
            "default": 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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}