Skip to content

Curl ​

功能概述 ​

本篇提供以 curl 指令直接调用 Dashboard Data API 的示例,适合用于快速验证 API 密钥与请求格式,或集成到自动化脚本中。

前置需求 ​

已获取有效的 API 密钥(在左侧菜单〔Dashboard〕→〔仪表板 API 密钥〕创建),详见 Dashboard Data API。

使用示例 ​

下列示例调用「获取标签历史数据」API(POST /dashboard/api/v2/open_api/history),获取两个标签在指定时间范围内、以每小时平均值汇总的历史数据。使用时请将 {your API key} 替换为实际的 API 密钥,并按需调整 start、end、tags 等参数:

bash
curl -X POST "https://www.weincloud.net/open-api/dashboard/api/v2/open_api/history" \
-H "X-API-KEY: {your API key}" \
-H "Content-Type: application/json" \
-d '{
  "start": "2024-06-25T03:35:42.657Z",
  "end": "2024-06-25T04:35:42.657Z",
  "tags": [
    {
      "hw_key": "AAA",
      "name": "tag1"
    },
    {
      "hw_key": "BBB",
      "name": "tag2"
    }
  ],
  "every": "1h",
  "every_mode": "mean",
  "option": {
    "fill": "none",
    "derivative": false
  }
}'