{
  "openapi": "3.0.1",
  "info": {
    "title": "Social Media Sentiment Analyzer",
    "description": "Analyze social media sentiment for any keyword, hashtag, or brand across Reddit, YouTube, X/Twitter, and Instagram. Returns per-post sentiment, emotion, aspect breakdown, language, and toxicity, plus an AI brand-health report with top praise, complaints, and crisis signals.",
    "version": "1.0",
    "x-build-id": "DSjsOAT1Pfnkq3wwk"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/khadinakbar~social-media-sentiment-analyzer/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-khadinakbar-social-media-sentiment-analyzer",
        "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/khadinakbar~social-media-sentiment-analyzer/runs": {
      "post": {
        "operationId": "runs-sync-khadinakbar-social-media-sentiment-analyzer",
        "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/khadinakbar~social-media-sentiment-analyzer/run-sync": {
      "post": {
        "operationId": "run-sync-khadinakbar-social-media-sentiment-analyzer",
        "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": [
          "query"
        ],
        "properties": {
          "query": {
            "title": "Search query, hashtag, or brand",
            "type": "string",
            "description": "The keyword, hashtag, brand, or topic to analyze across the selected platforms. Used as the search term for each source (e.g. 'Tesla', 'climate change', '#AI'). Defaults to 'ChatGPT'. NOT a profile or post URL — this is a search term, and the actor finds matching public posts and comments itself.",
            "default": "ChatGPT"
          },
          "platforms": {
            "title": "Platforms to analyze",
            "type": "array",
            "description": "Which social platforms to pull public posts and comments from. Reddit and YouTube work with no credentials. X/Twitter needs X auth cookies and Instagram needs Instagram session cookies (see Platform credentials) — if selected without credentials they are skipped with a warning. Defaults to Reddit + YouTube.",
            "items": {
              "type": "string",
              "enum": [
                "reddit",
                "youtube",
                "twitter",
                "instagram"
              ],
              "enumTitles": [
                "Reddit (no login)",
                "YouTube comments (no login)",
                "X / Twitter (needs cookies)",
                "Instagram hashtag (needs cookies)"
              ]
            },
            "default": [
              "reddit",
              "youtube"
            ]
          },
          "maxItems": {
            "title": "Max posts to analyze (total)",
            "minimum": 10,
            "maximum": 1000,
            "type": "integer",
            "description": "Hard cap on how many posts/comments to analyze across all platforms combined; the budget is split evenly across selected platforms. Default 100, range 10-1000. Each analyzed post costs $0.003, so this directly bounds this actor's per-post charges. The underlying scrapers' own charges are billed separately.",
            "default": 100
          },
          "timeRange": {
            "title": "Time window",
            "enum": [
              "24h",
              "7d",
              "30d",
              "all"
            ],
            "type": "string",
            "description": "How far back to look for posts, where the platform supports it. '24h' for breaking/crisis monitoring, '7d' for launch tracking, '30d' for steady-state, 'all' for no limit. Default '7d'. Some sources (e.g. Instagram hashtag) ignore this and always return the most recent posts.",
            "default": "7d"
          },
          "engine": {
            "title": "Sentiment engine",
            "enum": [
              "llm",
              "lexicon"
            ],
            "type": "string",
            "description": "'llm' (default) uses an AI model (Claude Haiku or GPT-4o-mini) via the actor's managed key for rich per-post sentiment, emotion, aspect-based breakdown, language detection, and optional toxicity — best quality and multilingual. 'lexicon' uses a fast offline word-list scorer returning polarity only — cheaper and English-only. If 'llm' is selected but no API key is available, the actor falls back to 'lexicon' with a warning.",
            "default": "llm"
          },
          "llmProvider": {
            "title": "LLM provider",
            "enum": [
              "anthropic",
              "openai"
            ],
            "type": "string",
            "description": "Preferred LLM provider when engine is 'llm'. The actor uses its managed key automatically (Claude Haiku if an Anthropic key is configured, otherwise GPT-4o-mini). Provide your own key in the LLM API key field to use your quota for either provider. Ignored when engine is 'lexicon'.",
            "default": "anthropic"
          },
          "llmApiKey": {
            "title": "LLM API key (optional, BYOK)",
            "type": "string",
            "description": "Bring your own API key for the selected provider to use your own quota instead of the managed key. For Anthropic use a key starting 'sk-ant-', for OpenAI a key starting 'sk-'. Leave blank to use the actor's managed Anthropic key (Anthropic only). Stored encrypted and never logged."
          },
          "includeToxicity": {
            "title": "Score toxicity",
            "type": "boolean",
            "description": "When enabled, the AI engine also returns a 0-1 toxicity score per post (hate, harassment, threats, profanity). Useful for community moderation and brand-safety screening. Adds reasoning per post but no extra per-post fee. Only applies when engine is 'llm'; ignored for lexicon.",
            "default": false
          },
          "includeReport": {
            "title": "Generate AI brand-health report",
            "type": "boolean",
            "description": "If true (default), after scoring individual posts the AI produces one aggregate brand-health report: overall score (0-100), sentiment split, emotion distribution, top praise themes, top complaints, crisis signals, and recommendations. Adds a $0.10 report fee. Set false to get per-post sentiment only.",
            "default": true
          },
          "responseFormat": {
            "title": "Per-post detail level",
            "enum": [
              "concise",
              "detailed"
            ],
            "type": "string",
            "description": "'concise' returns short text + sentiment label + score per post (~90 tokens/item — best for AI agents). 'detailed' returns full text, author, engagement, URL, emotions, aspects, language, and toxicity (~280 tokens/item — best for dashboards). Default 'detailed'. Does not affect the aggregate report.",
            "default": "detailed"
          },
          "xAuthToken": {
            "title": "X (Twitter) auth_token cookie",
            "type": "string",
            "description": "Your x.com 'auth_token' cookie, required only if 'twitter' is selected. Get it from your browser: F12 → Application → Cookies → x.com → auth_token. Keep it secret — it grants account access. Leave blank to skip X/Twitter."
          },
          "xCt0": {
            "title": "X (Twitter) ct0 cookie",
            "type": "string",
            "description": "Your x.com 'ct0' CSRF cookie, from the same browser session as auth_token. Get it via F12 → Application → Cookies → x.com → ct0. Required together with auth_token when 'twitter' is selected. Leave blank to skip X/Twitter."
          },
          "instagramSessionCookies": {
            "title": "Instagram session cookies",
            "type": "string",
            "description": "Your instagram.com cookie string, required only if 'instagram' is selected. Get it via F12 → Application → Cookies → instagram.com (the 'sessionid' and 'csrftoken' values matter most). Without it Instagram returns a login wall and is skipped. Leave blank to skip Instagram."
          },
          "maxCostUsd": {
            "title": "Max cost ceiling (USD)",
            "minimum": 0,
            "type": "number",
            "description": "Hard cap on THIS actor's own PPE charges (start + per-post + report) per run; it stops gracefully when reached. Does NOT include the underlying scrapers' own charges, which are billed separately. Leave at 0 for no cap. Accepts decimals, e.g. 0.5 stops this actor after $0.50 of its own charges.",
            "default": 0
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}