{
  "openapi": "3.0.1",
  "info": {
    "title": "Bilibili Scraper B站: Comments, Danmaku 弹幕 & Videos",
    "description": "Bilibili (哔哩哔哩, B站) scraper API: comments with full reply threads, danmaku (弹幕 bullet comments) from $1 per 1,000, videos, subtitles, creator profiles, search and trending. AI sentiment analysis. No login. B站爬虫 · 评论/弹幕采集 to JSON, CSV or Excel.",
    "version": "1.0",
    "x-build-id": "OKmrUDniOK4eMGwj9"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/molded_mountainpass~bilibili-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-molded_mountainpass-bilibili-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/molded_mountainpass~bilibili-scraper/runs": {
      "post": {
        "operationId": "runs-sync-molded_mountainpass-bilibili-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/molded_mountainpass~bilibili-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-molded_mountainpass-bilibili-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": [
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "What to scrape",
            "enum": [
              "videos",
              "comments",
              "danmaku",
              "subtitles",
              "users"
            ],
            "type": "string",
            "description": "Row type to output. Pick Danmaku here to get bullet comments; the danmaku settings further down only tune that mode. Videos are discovered from the sources below; comments, danmaku and subtitles are then collected for every discovered video. 'users' outputs creator profiles for the given user IDs / space URLs. Only 'subtitles' needs the SESSDATA cookie below.",
            "default": "videos"
          },
          "startUrls": {
            "title": "Start URLs",
            "type": "array",
            "description": "Video URLs (bilibili.com/video/BV…, b23.tv short links), creator pages (space.bilibili.com/123) or search pages (search.bilibili.com/all?keyword=…).",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "videoIds": {
            "title": "Video IDs",
            "type": "array",
            "description": "BV ids or av ids.",
            "items": {
              "type": "string"
            }
          },
          "searchQueries": {
            "title": "Search keywords",
            "type": "array",
            "description": "Each keyword is searched and up to 'Max videos per source' results are used.",
            "items": {
              "type": "string"
            }
          },
          "userIds": {
            "title": "Creator IDs (UID / mid)",
            "type": "array",
            "description": "In 'users' mode: profiles. In other modes: the creator's uploads are used as videos.",
            "items": {
              "type": "string"
            }
          },
          "feed": {
            "title": "Feed",
            "enum": [
              "none",
              "popular",
              "ranking"
            ],
            "type": "string",
            "description": "Also take videos from the popular feed or the top-100 ranking.",
            "default": "none"
          },
          "rankingCategory": {
            "title": "Ranking category id",
            "type": "integer",
            "description": "0 = all. E.g. 1 animation, 3 music, 4 games, 36 knowledge, 188 tech, 160 life, 211 food.",
            "default": 0
          },
          "maxItems": {
            "title": "Max output items",
            "minimum": 1,
            "type": "integer",
            "description": "Hard cap on billable rows for the whole run.",
            "default": 1000
          },
          "maxVideosPerSource": {
            "title": "Max videos per source",
            "minimum": 1,
            "type": "integer",
            "description": "Per search keyword, creator or feed.",
            "default": 50
          },
          "publishedAfter": {
            "title": "Only newer than",
            "type": "string",
            "description": "Absolute date (2024-05-01) or relative ('7 days', '12 hours'). Applies to videos and comments; pagination stops early where possible, which keeps runs cheap."
          },
          "publishedBefore": {
            "title": "Published before",
            "type": "string",
            "description": "Absolute date (2024-05-01) or relative ('30 days'). Skips videos published later. Search applies it on Bilibili's side, at no extra cost."
          },
          "searchOrder": {
            "title": "Search sort",
            "enum": [
              "totalrank",
              "click",
              "pubdate",
              "dm",
              "stow",
              "scores"
            ],
            "type": "string",
            "description": "Order of search results. Bilibili returns at most 1,000 results per search.",
            "default": "totalrank"
          },
          "searchDuration": {
            "title": "Search: video length",
            "enum": [
              "any",
              "short",
              "medium",
              "long",
              "very_long"
            ],
            "type": "string",
            "description": "Only return search results of this length. Bilibili filters them itself, at no extra cost.",
            "default": "any"
          },
          "uploadOrder": {
            "title": "Creator uploads sort",
            "enum": [
              "pubdate",
              "click",
              "stow"
            ],
            "type": "string",
            "description": "Order of a creator's uploads. With 'Newest', 'Published after' stops pagination at the first older upload.",
            "default": "pubdate"
          },
          "fullDetails": {
            "title": "Fetch full details for discovered videos",
            "type": "boolean",
            "description": "Search/creator/feed rows already contain title, views, duration, etc. Enable to fetch the full detail record (likes, coins, shares, parts) for each — one extra request per video.",
            "default": false
          },
          "includeTags": {
            "title": "Include tags",
            "type": "boolean",
            "description": "Adds the video's tags to each video row (one extra request per video).",
            "default": false
          },
          "danmakuProfile": {
            "title": "Add a danmaku profile to each video (no login needed)",
            "type": "boolean",
            "description": "Adds danmaku_profile to video rows: how many danmaku are in the recent pool, a 20-slice density timeline, the busiest moment, the most repeated phrases and text samples. One extra request per video, plus the detail request when the video came from a search, creator or feed listing. No extra charge.",
            "default": false
          },
          "danmakuSamplesPerVideo": {
            "title": "Danmaku text samples per video",
            "minimum": 0,
            "maximum": 200,
            "type": "integer",
            "description": "How many danmaku texts the profile includes, spread evenly over the video.",
            "default": 25
          },
          "commentsSamplePerVideo": {
            "title": "Embed top comments in video rows",
            "minimum": 0,
            "type": "integer",
            "description": "Adds the N hottest comments to each video row (no extra charge per comment).",
            "default": 0
          },
          "maxCommentsPerVideo": {
            "title": "Max comments per video",
            "minimum": 0,
            "type": "integer",
            "description": "Top-level comments per video, 0 = all. Replies (if included) come on top. No login needed.",
            "default": 200
          },
          "commentSort": {
            "title": "Comment sort",
            "enum": [
              "hot",
              "time"
            ],
            "type": "string",
            "description": "Hottest first, or newest first. With 'Newest', 'Published after' stops pagination at the first older comment.",
            "default": "hot"
          },
          "includeReplies": {
            "title": "Include nested replies",
            "type": "boolean",
            "description": "Also output the nested replies under each comment.",
            "default": false
          },
          "maxDanmakuPerVideo": {
            "title": "Max danmaku per video",
            "minimum": 0,
            "type": "integer",
            "description": "Only used when 'What to scrape' (at the top) is Danmaku. 0 = everything Bilibili serves.",
            "default": 0
          },
          "danmakuSource": {
            "title": "Danmaku source",
            "enum": [
              "both",
              "protobuf",
              "xml"
            ],
            "type": "string",
            "description": "Only used when 'What to scrape' (at the top) is Danmaku. Bilibili serves a sample spread over the video's lifetime (protobuf segments) and the most recent pool of a few thousand (XML). They barely overlap, so 'both' returns the most danmaku for one extra request per video.",
            "default": "both"
          },
          "allParts": {
            "title": "All parts of multi-part videos",
            "type": "boolean",
            "description": "Only used when 'What to scrape' is Danmaku or Subtitles. Danmaku and subtitles for every part (P1, P2, …) of a multi-part video, instead of only the first.",
            "default": false
          },
          "subtitleLanguages": {
            "title": "Subtitle languages",
            "type": "array",
            "description": "Only used when 'What to scrape' (at the top) is Subtitles. Only these subtitle tracks, by language code, for example ai-zh (AI Chinese captions), zh-CN, zh-Hans or en-US. Leave empty for every track. The 'subtitles' mode needs a SESSDATA cookie (see 'Access & performance').",
            "items": {
              "type": "string"
            }
          },
          "sentimentAnalysis": {
            "title": "Sentiment analysis",
            "type": "boolean",
            "description": "Labels every comment and danmaku positive, neutral or negative with a score from -1 to 1, using an AI model that understands Bilibili slang. Video rows get a summary over their danmaku samples and embedded top comments (turn on 'danmaku profile' or 'top comments'). Charged per label as a 'sentiment' event.",
            "default": false
          },
          "sentimentApiKey": {
            "title": "Your Groq API key (needed for sentiment)",
            "type": "string",
            "description": "Free key from console.groq.com (no card needed), or a key for the provider below. Sentiment analysis needs one. Stored encrypted."
          },
          "sentimentModel": {
            "title": "Model",
            "type": "string",
            "description": "Model name at the provider. Default: GPT-OSS 120B on Groq. If the provider has retired the model, the actor picks the best available one and logs which.",
            "default": "openai/gpt-oss-120b"
          },
          "sentimentApiUrl": {
            "title": "Provider API URL",
            "type": "string",
            "description": "Any OpenAI-compatible chat completions API. Default: Groq.",
            "default": "https://api.groq.com/openai/v1"
          },
          "onlyNewItems": {
            "title": "Only new items (delta mode)",
            "type": "boolean",
            "description": "Skip videos/comments/danmaku already returned by earlier runs with the same sources. You pay only for what is new — ideal for scheduled monitoring.",
            "default": false
          },
          "deltaKey": {
            "title": "Delta key",
            "type": "string",
            "description": "Optional name to share delta history between tasks. Defaults to a hash of mode + sources."
          },
          "sessdata": {
            "title": "SESSDATA cookie (optional)",
            "type": "string",
            "description": "Login cookie from a bilibili.com account (not bilibili.tv). Needed only for the 'subtitles' mode; every other mode, comments included, works without it. In your browser, log in to bilibili.com, open DevTools (F12) > Application > Cookies > https://www.bilibili.com and copy the full SESSDATA value from the Cookie Value pane (about 200 characters). Step-by-step guide in the README. Stored encrypted."
          },
          "proxyStrategy": {
            "title": "Proxy strategy",
            "enum": [
              "auto",
              "none",
              "datacenter",
              "residential",
              "custom"
            ],
            "type": "string",
            "description": "'Auto' starts with no proxy (cheapest) and escalates to datacenter, then residential proxies only if Bilibili starts blocking.",
            "default": "auto"
          },
          "proxyCountry": {
            "title": "Residential proxy country",
            "type": "string",
            "description": "Two-letter code, e.g. HK, TW, SG. Empty = any."
          },
          "proxyConfiguration": {
            "title": "Custom proxy",
            "type": "object",
            "description": "Used only with the 'Custom' strategy.",
            "default": {
              "useApifyProxy": false
            }
          },
          "maxRequestsPerSecond": {
            "title": "Max requests per second",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "Upper limit on requests to Bilibili. Higher is faster but triggers more risk-control blocks.",
            "default": 4
          },
          "maxConcurrency": {
            "title": "Videos processed in parallel",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "How many videos are scraped at the same time (still bounded by the request rate).",
            "default": 4
          },
          "healthCheck": {
            "title": "Fail the run if nothing is scraped",
            "type": "boolean",
            "description": "For scheduled monitoring: marks the run as failed (so Apify can email you) when it returns no rows or any error row.",
            "default": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}