Skip to content

设备接口

设备管理相关的 API 接口。

注册设备

绑定新设备到当前用户。

请求

http
POST /api/devices
Authorization: Bearer <token>
Content-Type: application/json

请求体

json
{
  "sn": "MG1-2024-001234",
  "mac": "AA:BB:CC:DD:EE:FF",
  "productModel": "Mooting G1"
}

请求字段

字段类型必填说明
snstring设备序列号
macstringMAC 地址
productModelstring产品型号

响应

成功 (200):

json
{
  "sn": "MG1-2024-001234",
  "userId": 123,
  "mac": "AA:BB:CC:DD:EE:FF",
  "productModel": "Mooting G1",
  "createdAt": "2026-01-29T10:30:00Z"
}

获取设备列表

获取当前用户的所有设备。

请求

http
GET /api/devices
Authorization: Bearer <token>

响应

成功 (200):

json
[
  {
    "sn": "MG1-2024-001234",
    "userId": 123,
    "mac": "AA:BB:CC:DD:EE:FF",
    "productModel": "Mooting G1",
    "createdAt": "2026-01-29T10:30:00Z"
  },
  {
    "sn": "MG1-2024-005678",
    "userId": 123,
    "mac": "11:22:33:44:55:66",
    "productModel": "Mooting G1",
    "createdAt": "2026-01-28T09:15:00Z"
  }
]

响应字段

字段类型说明
snstring设备序列号
userIdnumber所属用户 ID
macstringMAC 地址
productModelstring产品型号
createdAtstring绑定时间 (ISO 8601)

Mooting 开发者文档