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
  }
}'