跳到正文

获取设备 GET ​

通过唯一标识符获取指定设备的详细信息。

端点 ​

GET https://api.pocketalert.app/v1/devices/{tid}

身份验证 ​

必填

在请求中包含以下任一请求头:

  • Token: <your-api-key> — 在 API 密钥 页面获取
  • Authorization: Bearer <jwt-token> — 通过 登录 接口获取

请求 ​

路径参数 ​

参数类型必填描述
tidstring✅设备唯一标识符

请求头 ​

请求头必填描述
Token✅你的 API 密钥
Authorization✅Bearer <jwt-token>

请求示例 ​

bash
curl -X GET "https://api.pocketalert.app/v1/devices/9dc24hqldvv2bfx2nlc6r" \
  -H "Token: your-api-key"
javascript
const tid = '9dc24hqldvv2bfx2nlc6r';
const response = await fetch(`https://api.pocketalert.app/v1/devices/${tid}`, {
  headers: { 'Token': 'your-api-key' }
});
const device = await response.json();
python
import requests

tid = '9dc24hqldvv2bfx2nlc6r'
response = requests.get(
    f'https://api.pocketalert.app/v1/devices/{tid}',
    headers={'Token': 'your-api-key'}
)
print(response.json())
php
$tid = '9dc24hqldvv2bfx2nlc6r';
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->get('https://api.pocketalert.app/v1/devices/'.$tid);

return $response->json();

响应 ​

成功响应 ​

200 OK

返回设备对象

字段类型描述
tidstring设备唯一标识符
namestring设备名称
serial_numberstring设备序列号
is_activeboolean设备是否处于激活状态
created_atstring注册时间戳
json
{
  "tid": "9dc24hqldvv2bfx2nlc6r",
  "name": "iPhone 15 Pro",
  "serial_number": "123456-OK91-KLAI-8K91-32A0AKSA28X2",
  "is_active": true,
  "created_at": "12.06.2023 02:48:49"
}

错误响应 ​

状态码描述
401未授权 — 令牌无效或缺失
404未找到 — 设备不存在

Pocket Alert 文档