http://YOUR_SERVER_IP:5000
請將 YOUR_SERVER_IP 替換為您的伺服器 IP 或網域名稱
所有 API 端點都需要提供 API Key,可透過以下兩種方式:
X-API-Key: your-api-key?api_key=your-api-key預設 Demo Key: demo-key-12345(每小時 10,000 次請求)
速率限制: 根據 API Key 而定,超過限制會回傳 429 錯誤
如何取得 API Key: 請聯繫系統管理員或使用預設 demo key 進行測試
取得測站列表
參數:
範例:
/api/v1/stations?county=雲林縣&api_key=demo-key-12345
查詢觀測資料
參數:
範例:
/api/v1/observations?start=2025-10-20&end=2025-10-30&county=雲林縣&limit=100&api_key=demo-key-12345
cURL 範例(使用 Header):
curl -H "X-API-Key: demo-key-12345" "http://127.0.0.1:5000/api/v1/observations?start=2025-10-20&end=2025-10-30&county=雲林縣"
排行榜查詢
參數:
範例:
/api/v1/ranking?start=2025-10-20&end=2025-10-30&top=50&api_key=demo-key-12345
JavaScript (Fetch):
fetch('http://YOUR_SERVER_IP:5000/api/v1/ranking?start=2025-10-20&end=2025-10-30&top=10&api_key=demo-key-12345')
.then(r => r.json())
.then(data => console.log(data));
Python (requests):
import requests
url = 'http://YOUR_SERVER_IP:5000/api/v1/ranking'
params = {
'start': '2025-10-20',
'end': '2025-10-30',
'top': 10,
'api_key': 'demo-key-12345'
}
response = requests.get(url, params=params)
print(response.json())