779 字
4 分钟

Deploy a Danmu Server for Your Movie Watching: danmu_api

What is danmu_api#

danmu_api is an open-source JS danmu API backend project designed to let anyone easily deploy a danmu interface server. It supports fetching danmu directly from multiple video platforms (such as iQIYI, Youku, Tencent Video, Mango TV, Bilibili, etc.) without having to download danmu files in advance. Compared with another danmu service, misaka_danmu_server, it is more lightweight and simpler to deploy. If your needs are relatively light, this might be a better fit. Let’s first look at how to deploy danmu_api.

Main features include:

  • Compatible with Dandanplay (a danmu player), supporting its search, detail query, and danmu-fetch APIs.
  • Supports logging so you can view recent operation logs.
  • Multiple deployment options: local, Docker, Vercel, Cloudflare, EdgeOne, and more.
  • Configurable via environment variables, with options to toggle behavior such as token, which third-party danmu server to use as a fallback, concurrency, cookies, etc.
  • Implemented in JavaScript (Node.js).
huangxd-
/
danmu_api
Waiting for api.github.com...
00K
0K
0K
Waiting...
l429609201
/
misaka_danmu_server
Waiting for api.github.com...
00K
0K
0K
Waiting...

Feature Overview#

From the README, it provides the following APIs and features: GitHub

FeatureExample EndpointUsage / Notes
Search animeGET /api/v2/search/anime?keyword=${queryTitle}Search anime by keyword. GitHub
Match anime by titlePOST /api/v2/matchFor automatic matching: find the corresponding anime by a given keyword. GitHub
Search episodesGET /api/v2/search/episodesSearch for all matching episodes. GitHub
Get anime detailsGET /api/v2/bangumi/:animeIdRetrieve detailed data for a specific anime. GitHub
Get danmu commentGET /api/v2/comment/:commentId?withRelated=true&chConvert=1Get the danmu content of a specific comment, with support for related comments and character conversion. GitHub
LogsGET /api/logsRecent logs (up to 500 lines), including both info and error level output. GitHub

Feature Comparison#

Featuredanmu_apimisaka_danmu_server
Basic danmu fetching + API
API compatibility (Dandanplay / others)Yes, compatible with Dandanplay APIs, etc.Yes, follows the Dandanplay API spec and also supports custom player APIs (token routes, etc.).
Media library / metadata matching—— (lighter weight)✅ Supports media library management + metadata from TMDB, TVDB, Bangumi, Douban, IMDb, etc.
Web admin UI——✅ Provides a Web UI to manage danmu library, search sources, episodes, tokens, etc.
Auto-sync / Webhook integration——✅ Supports Sonarr, Radarr, Emby, and other media servers triggering automatic danmu import via Webhooks.
Logs / history / debuggingdanmu_api has log endpoints, etc.misaka_danmu_server provides logs + background task status monitoring + UI-based system settings.
Multi-source config / search prioritySome environment variables to switch sourcesMore powerful: configure multiple search sources, enable/disable, and set priority in the Web UI.
Security / API authorizationdanmu_api has token configuration, etc.misaka offers a more complete token auth system with a management UI, plus permissions and an account system.

Deployment#

One-click deployment#

In general, it’s recommended to fork the repo and deploy manually rather than using the official one-click deploy button, as the latter cannot automatically pull updates.

image-20250923105842186

image-20250923105907900

image-20250923105014843

  • Set environment variables: After deployment, in the Vercel dashboard:
    1. Go to your project settings.
    2. In the “Environment Variables” section, add a TOKEN variable and enter your API token.
    3. Save the changes and redeploy.
  • Example request: https://{your_domian}.vercel.app/87654321/api/v2/search/anime?keyword=子夜归

Set up a custom domain#

Be sure to bind a custom domain. The default Vercel domain, even if you choose Hong Kong, is usually blocked or throttled from mainland China.

image-20250923105150433

Set the Token environment variable#

Of course, you can also set this token when you first deploy. The steps here are for when you need to change the token later.

image-20250923105243534

Update function regions#

By default, the functions run in the US, which offers only average speed for CN users. You should switch regions according to your needs. But if, like me, you’re not on a Pro plan, you can only choose one region.

You need to disable the US region first, then select Hong Kong, and finally redeploy.

image-20250923105419610

Docker Deployment#

  1. Pull the image:

    docker pull logvar/danmu-api:latest
  2. Run the container:

    docker run -d -p 9321:9321 --name danmu-api -e TOKEN=your_token_here logvar/danmu-api:latest
    • Use -e TOKEN=your_token_here to set the TOKEN environment variable.
    services:
    danmu-api:
    image: logvar/danmu-api:latest
    container_name: danmu-api
    ports:
    - "9321:9321"
    environment:
    - TOKEN=your_token_here # 请将your_token_here 替换为实际的 Token 值
    restart: unless-stopped # 可选配置,容器退出时自动重启(非必需,可根据需求删除)
    • Or deploy with Docker Compose.
  3. Test the API: Use http://{ip}:9321/{TOKEN} to access the above APIs. If you need a domain name, you can put it behind a CDN, set the origin to this IP and port, and you’re good to go.

Using the API#

Supported players include forward / senplayer / hills / 小幻 / yamby / eplayerx / afusekt and other players that support danmu APIs.

Take senplayer as an example:

  1. Get the API address of your deployment, e.g. http://192.168.1.7:9321/87654321, where 87654321 is the default token. If you set a custom TOKEN environment variable, replace it with your actual token.
  2. Enter the API address in the custom danmu API field under Settings - Danmu Settings - Custom Danmu API.
  3. In the playback screen, click Danmu button - Search danmu, select your danmu API, and it will search based on the title. Wait for a while and then choose the episode.

image-20250923110203319

Note: when configuring the API in 小幻, you need to append /api/v2 to the API base, e.g. https://{your_project}.vercel.app/87654321/api/v2.

Deploy a Danmu Server for Your Movie Watching: danmu_api
https://catcat.blog/en/deploy-danmu_api.html
作者
猫猫博客
发布于
2025-09-23
许可协议
CC BY-NC-SA 4.0