mirror of
https://github.com/jxxghp/MoviePilot-Plugins.git
synced 2026-05-24 07:26:52 +00:00
18 lines
757 B
Markdown
18 lines
757 B
Markdown
# 如何在插件中对外暴露API?
|
||
|
||
返回 [README](../../README.md) | [FAQ 索引](../FAQ.md)
|
||
|
||
- 实现 `get_api()` 方法,按以下格式返回API列表:
|
||
```json
|
||
[{
|
||
"path": "/refresh_by_domain", // API路径,必须以/开始
|
||
"endpoint": self.refresh_by_domain, // API响应方法
|
||
"methods": ["GET"], // 请求方式:GET/POST/PUT/DELETE
|
||
"summary": "刷新站点数据", // API名称
|
||
"description": "刷新对应域名的站点数据", // API描述
|
||
}]
|
||
```
|
||
注意:在插件中暴露API接口时注意安全控制,推荐使用`settings.API_TOKEN`进行身份验证。
|
||
|
||
- 在对应的方法中实现API响应方法逻辑,通过 `http://localhost:3001/docs` 查看API文档和调试
|