{
  "openapi": "3.1.0",
  "info": {
    "title": "Social Media Scraper API",
    "version": "2026-11-23.2",
    "description": "197 customer operations; four upstream account operations are internal only. Send authenticated requests with the documented inputs and published price version."
  },
  "servers": [
    {
      "url": "https://socialmediascraper.org"
    }
  ],
  "paths": {
    "/v1/facebook/adlibrary_search_ads": {
      "get": {
        "operationId": "facebook_adlibrary_search_ads",
        "summary": "Facebook Ad Library Search (GET) API",
        "tags": [
          "facebook"
        ],
        "description": "Search Facebook Ad Library with URL query parameters to find public ads matching a keyword.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Search text used to find matching public content.",
            "example": "running"
          },
          {
            "name": "sort_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "total_impressions",
                "relevancy_monthly_grouped"
              ]
            },
            "description": "Ordering of returned results. Choose one of the allowed sort modes below.",
            "example": "total_impressions"
          },
          {
            "name": "search_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "keyword_unordered",
                "keyword_exact_phrase"
              ]
            },
            "description": "Result category or content format to include. Use an allowed value below.",
            "example": "keyword_unordered"
          },
          {
            "name": "ad_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "political_and_issue_ads"
              ]
            },
            "description": "Result category or content format to include. Use an allowed value below.",
            "example": "all"
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Country or region filter for the selected operation. Use the codes accepted below.",
            "example": "ALL"
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Language code for the transcript or language-specific result.",
            "example": "EN"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "ALL",
                "ACTIVE",
                "INACTIVE"
              ]
            },
            "description": "Status filter for the matching records.",
            "example": "ACTIVE"
          },
          {
            "name": "media_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "ALL",
                "IMAGE",
                "VIDEO",
                "MEME",
                "IMAGE_AND_MEME",
                "NONE"
              ]
            },
            "description": "Result category or content format to include. Use an allowed value below.",
            "example": "ALL"
          },
          {
            "name": "start_date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Beginning of the time range used to filter results.",
            "example": "2025-01-05"
          },
          {
            "name": "end_date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "End of the time range used to filter results.",
            "example": "2025-02-16"
          },
          {
            "name": "trim",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Request the supplier’s trimmed response representation.",
            "example": "false"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Continuation value from the preceding response. Keep the other search or target parameters unchanged when loading the next page.",
            "example": "AQHRYLVDkoMkvGv7yK1rcce-vJmKiKv330R4v3j9KHSOaYvmF1bq1QkotG0rgW8Fkrj-"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          },
          {
            "name": "x-price-version",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Pin the expected request-price version before billing."
          }
        ],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "JSON response containing request identity, normalized operation data and metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "meta": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                },
                "example": {
                  "request_id": "example-request-id",
                  "data": {
                    "platform": "facebook",
                    "resource": "adlibrary_search_ads",
                    "items": [
                      {
                        "id": "123456789",
                        "position": 0,
                        "url": "https://example.com/public-content",
                        "title": "Example public content",
                        "text": "Example public content",
                        "published_at": null,
                        "author": {
                          "id": "123456789",
                          "handle": "example",
                          "display_name": "Example creator"
                        },
                        "metrics": {
                          "views": null,
                          "likes": 12,
                          "comments": null,
                          "shares": null
                        }
                      }
                    ],
                    "cursor": null
                  },
                  "meta": {
                    "platform": "facebook",
                    "fetched_at": "2026-11-28T00:00:00.000Z",
                    "cached": false,
                    "schema_version": "2026-11-23.2",
                    "route_version": 1,
                    "billing": {
                      "capability": "facebook.adlibrary_search_ads",
                      "version": "2026-11-23.retail-1",
                      "currency": "USD",
                      "unit_scale": 1000000000,
                      "amount_units": 2444000,
                      "amount_usd": "0.002444000",
                      "billing_basis": "request"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Insufficient credits"
          },
          "429": {
            "description": "Customer request rate or concurrency limit. Follow Retry-After and retain the original request identity."
          },
          "503": {
            "description": "Service temporarily unavailable"
          }
        },
        "x-live-status": "awaiting_live_verification",
        "x-response-kind": "search",
        "x-price": {
          "capability": "facebook.adlibrary_search_ads",
          "version": "2026-11-23.retail-1",
          "currency": "USD",
          "unit_scale": 1000000000,
          "amount_units": 2444000,
          "amount_usd": "0.002444000",
          "billing_basis": "request"
        },
        "x-pagination-fields": [
          "cursor"
        ],
        "x-required-any-of": [],
        "x-input-rules": [],
        "x-documentation-url": "https://socialmediascraper.org/apis/facebook/adlibrary_search_ads/",
        "x-markdown-url": "https://socialmediascraper.org/api-reference/facebook.adlibrary_search_ads.md"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  }
}
