REST API 参考
SidecarOneStep 提供了 RESTful API,方便开发者集成。
基础信息
- 默认端口:
8765 - Base URL:
http://localhost:8765 - 鉴权: 如果在设置中开启了鉴权,需要在 Header 中添加
Authorization: Bearer <YOUR_API_KEY>。
接口列表
1. 获取设备列表
- URL:
/devices - Method:
GET - Response:
{ "code": 0, "message": "success", "data": { "devices": ["Joe's iPad", "iPad Pro"] } }
2. 连接设备
- URL:
/connect - Method:
POST - Body:
{ "name": "Joe's iPad", "wired": false }name为可选。若为空,则连接第一个可用设备。wired为true时强制使用有线模式。
3. 断开设备
- URL:
/disconnect - Method:
POST - Body:
{ "name": "Joe's iPad" }
4. 切换状态 (Toggle)
- URL:
/toggle - Method:
POST - Body:
{ "name": "Joe's iPad" }
Swagger 文档
应用开启调试模式后,访问 /docs 路径(例如 http://localhost:8765/docs)可查看交互式 Swagger UI 文档。
