{
  "openapi": "3.0.1",
  "info": {
    "title": "Facebook Comments Scraper",
    "description": "💬 Facebook Comments Scraper extracts post comments at scale—text, authors, timestamps, reactions, and threaded replies. ⚙️ Export CSV/JSON for analytics, sentiment, and reporting. 🚀 Ideal for social listening, CX, and research. ✅ Use on public or authorized data.",
    "version": "0.1",
    "x-build-id": "mquqlKaIpiBaLsQr1"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/scraper-engine~facebook-comments-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-scraper-engine-facebook-comments-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/scraper-engine~facebook-comments-scraper/runs": {
      "post": {
        "operationId": "runs-sync-scraper-engine-facebook-comments-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/scraper-engine~facebook-comments-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-scraper-engine-facebook-comments-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": [
          "startUrls"
        ],
        "properties": {
          "startUrls": {
            "title": "🔗 Paste your Facebook post / video links",
            "type": "array",
            "description": "📋 One URL per line — bulk paste from a spreadsheet is welcome.\n\n✅ Works with typical **post**, **photo**, and **reel** permalinks from facebook.com.\n\n💡 **Example:** `https://www.facebook.com/humansofnewyork/posts/...` — run a small test first, then scale up your max comments.",
            "items": {
              "type": "string"
            }
          },
          "commentSettings": {
            "title": "📊 Comments, replies & sort order",
            "type": "object",
            "description": "▶️ **One panel** — how many comments, how deep into reply threads, and which order. Tap the header to expand or collapse.",
            "properties": {
              "maxComments": {
                "title": "💬 Max comments per post (top-level only)",
                "type": "integer",
                "description": "🎯 Hard cap on **top-level** comments **per URL**. Replies do NOT count against this — they are fetched additionally and bounded by *Max replies per comment*.\n\n📌 **Example:** maxComments=10 + maxRepliesPerComment=3 → up to 10 comments and up to ~30 replies. Default is 10.",
                "editor": "number",
                "default": 10,
                "minimum": 1
              },
              "includeReplies": {
                "title": "↩️ Include replies",
                "type": "boolean",
                "description": "🧵 When on, the Actor fetches replies for each comment and emits each reply as its own row. Turn off to scrape top-level comments only. Default is on.",
                "default": true
              },
              "maxRepliesPerComment": {
                "title": "↩️ Max replies per comment",
                "type": "integer",
                "description": "🧵 Nested replies to fetch per threaded comment (across all depths). Use `0` for unlimited. Default is 3.",
                "editor": "number",
                "default": 3,
                "minimum": 0
              },
              "maxReplyDepth": {
                "title": "🪜 Max reply depth (1–3)",
                "type": "integer",
                "description": "🪜 How deep to follow reply-to-reply threads. `1` = only direct replies (Facebook default). `2`–`3` = also fetch replies to replies. Default is 1.",
                "editor": "number",
                "default": 1,
                "minimum": 1,
                "maximum": 3
              },
              "emitRepliesAsSeparateRows": {
                "title": "🧩 Emit replies as their own rows",
                "type": "boolean",
                "description": "🧩 When on (recommended), each reply is a separate dataset row with `type=reply`, `isReply=true`, and `replyToId`. When off, replies are nested under the parent comment's `reply[]` array. Default is on.",
                "default": true
              },
              "commentsSortOrder": {
                "title": "📊 Comment order",
                "type": "string",
                "description": "🔀 Ordering of top-level comments before the *Max comments* cap is applied.",
                "editor": "select",
                "enum": [
                  "most_relevant",
                  "newest",
                  "all"
                ],
                "enumTitles": [
                  "⭐ Most relevant (likes + replies)",
                  "🆕 Newest first",
                  "📜 All / original flow"
                ],
                "default": "all"
              }
            }
          },
          "searchKeywords": {
            "title": "🔍 Keywords to include (match any)",
            "type": "array",
            "description": "🔍 Keep only comments/replies whose text contains **at least one** of these words/phrases (case-insensitive). Leave empty to keep everything.\n\n📌 **Example:** `[\"love\", \"amazing\"]` keeps comments mentioning either word.",
            "items": {
              "type": "string"
            }
          },
          "excludeKeywords": {
            "title": "🚫 Keywords to exclude (match any)",
            "type": "array",
            "description": "🚫 Drop any comment/reply whose text contains **any** of these words/phrases (case-insensitive).\n\n📌 **Example:** `[\"spam\", \"http\"]` removes comments mentioning either.",
            "items": {
              "type": "string"
            }
          },
          "minLikes": {
            "title": "👍 Minimum likes / reactions",
            "minimum": 0,
            "type": "integer",
            "description": "👍 Keep only comments/replies with at least this many reactions. `0` = no minimum. Default is 0.",
            "default": 0
          },
          "authorNameContains": {
            "title": "🧑 Author name contains",
            "type": "string",
            "description": "🧑 Keep only comments/replies whose author display name contains this text (case-insensitive). Leave blank to disable."
          },
          "onlyCommentsOlderThan": {
            "title": "📅 Only comments older than",
            "type": "string",
            "description": "📅 Keep only comments/replies posted **before** this point. Pick an absolute date (e.g. `2024-01-15`) or a relative window (e.g. `1 day`, `2 weeks`, `3 months`). Leave blank to disable."
          },
          "aiEnhancement": {
            "title": "🤖 Enable AI enrichment",
            "type": "boolean",
            "description": "🤖 When on, each comment/reply is analyzed by the AI model below to add `aiSentiment`, `aiLanguage`, `aiTopics`, `aiIsSpam`, and `aiLeadScore`. Requires an API key (below). If no key is provided, AI is skipped with a warning. Default is off.",
            "default": false
          },
          "aiModel": {
            "title": "🤖 AI Model / Provider",
            "enum": [
              "claude-haiku-4-5",
              "claude-sonnet-5",
              "claude-opus-4-8",
              "claude-fable-5",
              "gpt-4o-mini",
              "gpt-4o",
              "gpt-4.1-mini",
              "gpt-4.1",
              "o3-mini",
              "o1",
              "gemini-2.0-flash-lite",
              "gemini-2.0-flash",
              "gemini-1.5-pro",
              "gemini-2.5-flash",
              "gemini-2.5-pro",
              "grok-2-latest",
              "grok-3-mini",
              "grok-3",
              "grok-beta",
              "deepseek-chat",
              "deepseek-reasoner",
              "sonar",
              "sonar-pro",
              "sonar-reasoning",
              "mistral-small-latest",
              "mistral-large-latest"
            ],
            "type": "string",
            "description": "Provider auto-detected from the name: claude-*=Anthropic, gpt-*/o1/o3=OpenAI, gemini-*=Google, grok-*=xAI, deepseek-*=DeepSeek, sonar*=Perplexity, mistral-*=Mistral. Cheaper mini/flash/haiku/lite models are recommended for classification.",
            "default": "claude-haiku-4-5"
          },
          "aiApiKey": {
            "title": "🔑 AI API key",
            "type": "string",
            "description": "🔑 Your provider API key (kept secret). If blank, the Actor falls back to the matching environment variable for the detected provider (e.g. ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, XAI_API_KEY, DEEPSEEK_API_KEY, PERPLEXITY_API_KEY, MISTRAL_API_KEY). If neither is set, AI enrichment is skipped."
          },
          "proxyConfiguration": {
            "title": "🌐 Proxy configuration",
            "type": "object",
            "description": "ℹ️ The scraper always attaches Apify **residential** proxy at runtime — Facebook requires it. This field is shown for transparency."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}