Appearance
设备数据
获取设备下所有因子的实时数据。
获取实时数据
GET /api/v2/projects/{project_id}/devices/{device_id}/data/响应示例
json
[
{
"agri_id": "d-1000-abc123-1-00",
"value": 25.6,
"the_type": 2001,
"unit": "℃",
"t": 1711008140
},
{
"agri_id": "d-1000-abc123-1-01",
"value": 65.2,
"the_type": 2002,
"unit": "%RH",
"t": 1711008140
}
]响应字段
| 字段 | 类型 | 描述 |
|---|---|---|
agri_id | string | 因子标识符 |
value | number | 当前值 |
the_type | integer | 因子类型 |
unit | string | 数据单位 |
t | integer | 时间戳(秒) |
bash
curl "https://dl.yengear.com/api/v2/projects/proj_abc/devices/123/data/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "X-Organization-Slug: your-org-slug"python
response = requests.get(
f"{API_BASE}/projects/{project_id}/devices/{device_id}/data/",
headers=headers
)
for item in response.json():
print(f"{item['agri_id']}: {item['value']} {item.get('unit', '')}")说明
- 返回设备下所有启用因子的最新数据
- 接口有缓存,缓存时间约 2 分钟
t字段为 UTC 时间戳(秒)
