REST API 参考

机器人

获取机器人列表

GET /v1/robots

示例

curl -H "Authorization: token hmp_f8cabe6159c963f6e3b30d248ac74e475500c815cfd52e2b225e8906cb2a3cf9" \
    https://api.hamibot.com/v1/robots

响应

200

{
  "count": 1,
  "items": [
    {
      "_id": "a51d237e9af41ecc021c9ff6",
      "online": true,
      "tags": ["tag1", "tag2"],
      "name": "零号机",
      "brand": "Xiaomi",
      "model": "MI 11"
    }
  ]
}

获取机器人

GET /v1/robots/{robotId}

示例

curl -H "Authorization: token hmp_f8cabe6159c963f6e3b30d248ac74e475500c815cfd52e2b225e8906cb2a3cf9" \
    https://api.hamibot.com/v1/robots/a51d237e9af41ecc021c9ff6

响应

200

{
  "_id": "a51d237e9af41ecc021c9ff6",
  "online": true,
  "tags": ["tag1", "tag2"],
  "name": "零号机",
  "brand": "Xiaomi",
  "model": "MI 11"
}

脚本

获取脚本列表

GET /v1/scripts

示例

curl -H "Authorization: token hmp_f8cabe6159c963f6e3b30d248ac74e475500c815cfd52e2b225e8906cb2a3cf9" \
    https://api.hamibot.com/v1/scripts

响应

200

{
  "count": 1,
  "items": [
    {
      "_id": "bfe67d643ababe0ab6fda054",
      "slug": "FLZoI",
      "name": "你好世界",
      "version": "1.1.3"
    }
  ]
}

获取脚本

GET /v1/scripts/{scriptId}

示例

curl -H "Authorization: token hmp_f8cabe6159c963f6e3b30d248ac74e475500c815cfd52e2b225e8906cb2a3cf9" \
    https://api.hamibot.com/v1/scripts/bfe67d643ababe0ab6fda054

响应

200

{
  "_id": "bfe67d643ababe0ab6fda054",
  "slug": "FLZoI",
  "name": "你好世界",
  "version": "1.1.3"
}

运行脚本

POST /v1/scripts/{scriptId}/run

参数

名称类型描述
robotsarray要执行脚本的机器人
varsobject可选,脚本配置

示例

curl \
    -X POST \
    -H "Authorization: token hmp_f8cabe6159c963f6e3b30d248ac74e475500c815cfd52e2b225e8906cb2a3cf9" \
    -H "Content-Type: application/json" \
    -d '{"robots": [{"_id": "a51d237e9af41ecc021c9ff6","name": "零号机"}]}' \
    https://api.hamibot.com/v1/scripts/bfe67d643ababe0ab6fda054/run

响应

204

Status: 204 No Content

422

参数错误

Status: 422 Unprocessable Entity