机器人

示例中的 _id 需要替换成你自己的
示例中的 hmp_... 需要替换为自己的令牌 获取令牌

获取机器人列表

GET /v1/robots

示例

Hamibot 示例

// hmp_... 需要替换成自己的
var res = http.request('https://api.hamibot.com/v1/robots', {
  method: 'GET',
  headers: {
    authorization: 'hmp_...',
  },
});
log(res.body.json());

curl 示例

curl -H "Authorization: hmp_..." \
    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}

示例

Hamibot 示例

// _id 和 hmp_... 需要替换成自己的
var res = http.request('https://api.hamibot.com/v1/robots/_id', {
  method: 'GET',
  headers: {
    authorization: 'hmp_...',
  },
});
log(res.body.json());

curl 示例

curl -H "Authorization: hmp_..." \
    https://api.hamibot.com/v1/robots/_id

响应

200 成功

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

停止所有脚本

PUT /v1/robots/{robotId}/stop

示例

Hamibot 示例

// _id 和 hmp_... 需要替换成自己的
http.request('https://api.hamibot.com/v1/robots/_id/stop', {
  method: 'PUT',
  headers: {
    authorization: 'hmp_...',
  },
});

curl 示例

curl -X PUT -H "Authorization: hmp_..." \
    https://api.hamibot.com/v1/robots/_id/stop

响应

204 成功

消息推送

最低版本要求:Hamibot 1.2.2 前往下载
感谢 sl1097643327git 提交本功能
POST /v1/robots/{robotId}/messages

参数

名称类型描述
titlestring标题,最大长度 128
textstring消息内容,最大长度 512

示例

Hamibot 示例

// _id 和 hmp_... 需要替换成自己的
http.request('https://api.hamibot.com/v1/robots/_id/messages', {
  method: 'POST',
  contentType: 'application/json',
  headers: {
    authorization: 'hmp_...',
  },
  body: JSON.stringify({ title: '标题', text: '消息内容' }),
});

curl 示例

curl \
    -X POST \
    -H "Authorization: hmp_..." \
    -H "Content-Type: application/json" \
    -d '{"title": "标题", "text": "消息内容"}' \
    https://api.hamibot.com/v1/robots/_id/messages

响应

204 成功