Skip to content

JS 插件

接口列表

方法路径说明
GET/api/v1/jsplugin-assets/{path}插件公共资源
GET/jsplugin/{entryPath}插件根页面(动态路由)
POST/jsplugin/{entryPath}/{path}插件 API 转发 catch-all(动态路由)
PUT/jsplugin/{entryPath}/{path}插件 API 转发 catch-all(动态路由)
DELETE/jsplugin/{entryPath}/{path}插件 API 转发 catch-all(动态路由)
GET/jsplugin/{entryPath}/{path}插件 API 转发 catch-all(动态路由)
HEAD/jsplugin/{entryPath}/files/{path}插件文件直接访问
GET/jsplugin/{entryPath}/files/{path}插件文件直接访问
GET/jsplugin/{entryPath}/static插件 static 目录根(动态路由)
GET/jsplugin/{entryPath}/static/{path}插件静态资源文件(动态路由)

GET /api/v1/jsplugin-assets/{path}

插件公共资源

服务由主程序嵌入的插件通用 CSS、JS 和字体文件,自动注入到所有插件 HTML 页面。

路径参数

参数类型必填说明
*string资源路径

响应

200 - 资源文件

404 - 资源不存在

类型: map[string]string

内容类型

  • 响应: application/octet-stream

GET /jsplugin/{entryPath}

插件根页面(动态路由)

JS 插件入口 HTML。{entryPath} 由运行时按已安装插件决定,注入 <base> 标签和 auth-bridge 脚本后返回 static/index.html。无需认证。

路径参数

参数类型必填说明
entryPathstring插件入口标识(运行时动态)

响应

200 - 插件 index.html(已注入 <base> 与 auth-bridge)

类型: string

404 - 插件未安装或缺 static/index.html

类型: string

内容类型

  • 响应: text/html

POST /jsplugin/{entryPath}/{path}

插件 API 转发 catch-all(动态路由)

接受任意 HTTP 方法,分发到插件 static 兜底、入站 WebSocket upgrade(调用 onWebSocket),或转发到 QuickJS 沙盒中的插件代码。{entryPath} 和子路径均由运行时决定,OpenAPI 仅作占位。需要 BearerAuth。

需要认证

此接口需要 Bearer Token 认证

路径参数

参数类型必填说明
entryPathstring插件入口标识(运行时动态)

请求头参数

参数类型必填说明
X-Plugin-Timeout-Msinteger可选:放宽本次插件调用的超时(毫秒),宿主 clamp 到 [30000, 300000]。慢端点(如 yt-dlp 展开歌单)用于避免默认 30s 超时

响应

200 - 插件自定义响应

类型: map[string]any

403 - 插件未启用

类型: map[string]string

404 - 插件不存在

类型: map[string]string

503 - 插件不可用或运行异常(健康检查会自愈)

类型: map[string]string

504 - JS 运行时调用超时

类型: map[string]string

内容类型

  • 请求: application/json
  • 响应: application/json

PUT /jsplugin/{entryPath}/{path}

插件 API 转发 catch-all(动态路由)

接受任意 HTTP 方法,分发到插件 static 兜底、入站 WebSocket upgrade(调用 onWebSocket),或转发到 QuickJS 沙盒中的插件代码。{entryPath} 和子路径均由运行时决定,OpenAPI 仅作占位。需要 BearerAuth。

需要认证

此接口需要 Bearer Token 认证

路径参数

参数类型必填说明
entryPathstring插件入口标识(运行时动态)

请求头参数

参数类型必填说明
X-Plugin-Timeout-Msinteger可选:放宽本次插件调用的超时(毫秒),宿主 clamp 到 [30000, 300000]。慢端点(如 yt-dlp 展开歌单)用于避免默认 30s 超时

响应

200 - 插件自定义响应

类型: map[string]any

403 - 插件未启用

类型: map[string]string

404 - 插件不存在

类型: map[string]string

503 - 插件不可用或运行异常(健康检查会自愈)

类型: map[string]string

504 - JS 运行时调用超时

类型: map[string]string

内容类型

  • 请求: application/json
  • 响应: application/json

DELETE /jsplugin/{entryPath}/{path}

插件 API 转发 catch-all(动态路由)

接受任意 HTTP 方法,分发到插件 static 兜底、入站 WebSocket upgrade(调用 onWebSocket),或转发到 QuickJS 沙盒中的插件代码。{entryPath} 和子路径均由运行时决定,OpenAPI 仅作占位。需要 BearerAuth。

需要认证

此接口需要 Bearer Token 认证

路径参数

参数类型必填说明
entryPathstring插件入口标识(运行时动态)

请求头参数

参数类型必填说明
X-Plugin-Timeout-Msinteger可选:放宽本次插件调用的超时(毫秒),宿主 clamp 到 [30000, 300000]。慢端点(如 yt-dlp 展开歌单)用于避免默认 30s 超时

响应

200 - 插件自定义响应

类型: map[string]any

403 - 插件未启用

类型: map[string]string

404 - 插件不存在

类型: map[string]string

503 - 插件不可用或运行异常(健康检查会自愈)

类型: map[string]string

504 - JS 运行时调用超时

类型: map[string]string

内容类型

  • 请求: application/json
  • 响应: application/json

GET /jsplugin/{entryPath}/{path}

插件 API 转发 catch-all(动态路由)

接受任意 HTTP 方法,分发到插件 static 兜底、入站 WebSocket upgrade(调用 onWebSocket),或转发到 QuickJS 沙盒中的插件代码。{entryPath} 和子路径均由运行时决定,OpenAPI 仅作占位。需要 BearerAuth。

需要认证

此接口需要 Bearer Token 认证

路径参数

参数类型必填说明
entryPathstring插件入口标识(运行时动态)

请求头参数

参数类型必填说明
X-Plugin-Timeout-Msinteger可选:放宽本次插件调用的超时(毫秒),宿主 clamp 到 [30000, 300000]。慢端点(如 yt-dlp 展开歌单)用于避免默认 30s 超时

响应

200 - 插件自定义响应

类型: map[string]any

403 - 插件未启用

类型: map[string]string

404 - 插件不存在

类型: map[string]string

503 - 插件不可用或运行异常(健康检查会自愈)

类型: map[string]string

504 - JS 运行时调用超时

类型: map[string]string

内容类型

  • 请求: application/json
  • 响应: application/json

HEAD /jsplugin/{entryPath}/files/{path}

插件文件直接访问

通过 Go 原生 http.ServeFile 直接返回插件可访问范围内的文件,支持 Range 请求和 HTTP 缓存。

需要认证

此接口需要 Bearer Token 认证

路径参数

参数类型必填说明
entryPathstring插件入口标识
pathstring文件路径

响应

200 - 文件内容

类型: file

206 - 部分文件内容(Range 请求)

类型: file

404 - 文件不存在或权限不足

类型: string

内容类型

  • 响应: application/octet-stream

GET /jsplugin/{entryPath}/files/{path}

插件文件直接访问

通过 Go 原生 http.ServeFile 直接返回插件可访问范围内的文件,支持 Range 请求和 HTTP 缓存。

需要认证

此接口需要 Bearer Token 认证

路径参数

参数类型必填说明
entryPathstring插件入口标识
pathstring文件路径

响应

200 - 文件内容

类型: file

206 - 部分文件内容(Range 请求)

类型: file

404 - 文件不存在或权限不足

类型: string

内容类型

  • 响应: application/octet-stream

GET /jsplugin/{entryPath}/static

插件 static 目录根(动态路由)

服务 static/index.html,是 handlePluginStatic 的「带 /static 后缀」变体。无需认证。

路径参数

参数类型必填说明
entryPathstring插件入口标识(运行时动态)

响应

200 - 插件 index.html

类型: string

404 - 插件未安装或缺 static/index.html

类型: string

内容类型

  • 响应: text/html

GET /jsplugin/{entryPath}/static/{path}

插件静态资源文件(动态路由)

从插件磁盘目录返回 CSS/JS/图片等静态资源;未命中且非 index.html 时 SPA fallback 到 index.html。无需认证。

路径参数

参数类型必填说明
entryPathstring插件入口标识(运行时动态)

响应

200 - 静态资源文件内容

类型: file

404 - 文件不存在且无 index.html fallback

类型: string

内容类型

  • 响应: application/octet-stream