2 個端點 · 商品 · 總體經濟
https://api.blave.orgapi-key 與 secret-key 標頭API plan or Blave Agent plan/studio/market/db/ohlcv/<dataset>/<symbol>/<schema> | 名稱 | 說明 | 可用值 | 預設 |
|---|---|---|---|
datasetstring · path必填 | 交易所資料集 | GLBX.MDP3(CME)、IFEU.IMPACT(ICE) | |
symbolstring · path必填 | 近月連續合約 | GLBX.MDP3:CL(WTI 原油)、GC(黃金);IFEU.IMPACT:BRN(布蘭特原油) | |
schemastring · path必填 | K 棒週期 | ohlcv-1d, ohlcv-1h, ohlcv-1m | |
startstring · query | 起始日 | YYYY-MM-DD | end − 該週期的最大區間 |
endstring · query | 結束日期 | YYYY-MM-DD | 今天(UTC) |
每次請求的最大區間(end − start):ohlcv-1d 3650 天 · ohlcv-1h 730 天 · ohlcv-1m 31 天。
data = requests.get(f"{BASE_URL}/studio/market/db/ohlcv/GLBX.MDP3/CL/ohlcv-1d" , headers=headers, params={"start": "2024-01-01", "end": "2024-12-31"}, timeout=60).json()["data"]# [{"ts": "2024-01-02 00:00:00+00:00", "open": 71.95, "high": 73.64, "low": 70.06, "close": 70.5,# "volume": 263594, "instrument_id": 686071},# {"ts": "2024-01-03 00:00:00+00:00", "open": 70.49, "high": 73.23, "low": 69.28, "close": 73.05,# "volume": 253755, "instrument_id": 686071}, ...]{"dataset", "symbol", "schema", "data": [...]}.
| 欄位 | 型別 | 單位 | 說明 |
|---|---|---|---|
ts | string | UTC ISO 格式 | K 棒開盤時間 |
open / high / low / close | float | 美元(原油:每桶;黃金:每盎司) | 價格 |
volume | int | 口 | 成交量 |
instrument_id | int | — | 上游的商品 id,從來源 K 棒原樣帶出 |
| 狀態碼 | 回應內容 | 情況 |
|---|---|---|
| 400 | {"error": "Invalid schema. Allowed: [...]"} | 週期不對 |
| 400 | {"error": "Invalid dataset/symbol combination"} | 組合不對 |
| 400 | {"error": "Invalid date format. Use YYYY-MM-DD"} | 日期格式錯誤 |
| 400 | {"error": "date_range_too_large", "message": "...", "max_days": <n>} | 區間超過上限 |
| 404 | 錯誤訊息 | 沒有資料 |
ohlcv-1m 歷史,請以 ≤ 31 天為一段分次請求再接起來(一段要幾秒)。/studio/market/anue/economic_calendar 全部選填;不篩選會回整份資料(約 1,400 列),所以一律要篩選。
| 名稱 | 說明 | 可用值 | 預設 |
|---|---|---|---|
startstring · query | 這個日期(含)之後的事件 | YYYY-MM-DD(台北日期) | 無下限 |
endstring · query | 這個日期(含)之前的事件 | YYYY-MM-DD(台北日期) | 無上限 |
countrystring · query | 國家篩選 | ISO-2 代碼,以逗號分隔,不分大小寫,例如 US,CN,TW | 所有國家 |
max_priorityint · query | 只留 priority <= max_priority。1 最重要,所以只看大事件 = max_priority=1 | 1 / 2 / 3 | 所有優先級 |
limitint · query | 依事件時間排序後只留前 N 筆 | ≥ 1 | 不限 |
langstring · query | countryName/subject 的顯示語言;伺服器對照表裡沒有的名稱會維持原樣,所以 en 會回中英混雜的結果 | en / zh | en |
params = {"start": "2026-09-16", "end": "2026-09-23", "max_priority": 1, "lang": "zh"}response = requests.get( f"{BASE_URL}/studio/market/anue/economic_calendar" , headers=headers, params=params, timeout=60,)data = response.json()# [{"id": 79382, "startDate": 1790121600, "date": 1788220800, "dateUnit": "month", "time": "16:30",# "countryId": "GB", "countryName": "英國", "areaId": "4",# "subject": "S&P Global Manufacturing PMI - 初值", "subjectTitle": "<9月>", "unit": "point",# "predict": 51.7, "last": 51.7, "real": None, "correct": None, "correctMark": "N",# "place": None, "priority": 1, "type": 2}, ...]一個裸的 JSON 陣列(沒有包在 {"data": ...} 裡)。順序是資料本身的順序,除非有設 limit(這時依 startDate、time 排序)。
| 欄位 | 型別 | 單位 | 說明 |
|---|---|---|---|
startDate | int | epoch 秒 | 事件的台北日曆日期 |
time | string | null | HH:MM 台北時間 | 公布時間;未公布時為 null |
countryId | string | ISO-2 | 國家代碼 |
countryName | string | — | 國家名稱(依 lang) |
subject | string | — | 指標名稱(依 lang) |
subjectTitle | string | — | 期間標籤,例如 <7月>、<2季> |
predict | number | null | unit | 市場預期 |
last | number | null | unit | 前值 |
real | number | null | unit | 實際值;公布前為 null |
unit | string | — | e.g. %, point, 億USD |
priority | int | 1–3 | 1 = 最重要(非農就業、利率決議),3 = 最不重要(鑽油井數) |
實際回應還帶了下列欄位,是從上游資料原樣帶出的。這裡只寫觀察到的內容,不要做更多解讀。
| 欄位 | 型別 | 觀察到的內容 |
|---|---|---|
id | int | 上游的事件 id,例如 79382 |
date | int | 數據所屬期間的 epoch 秒,不是公布時間:標示 subjectTitle: "<9月>" 的列,date = 2026-09-01,而 startDate 是 2026-09-23 |
dateUnit | string | month |
type | int | 2 |
areaId | string | "4" |
place | string | null | null |
correct | number | null | null |
correctMark | string | "N" |
| 狀態碼 | 回應內容 | 情況 |
|---|---|---|
| 400 | {"error": "Invalid date format. Use YYYY-MM-DD"} | start/end 格式錯誤 |
| 400 | {"error": "max_priority must be an integer"} | max_priority 不是整數 |
| 400 | {"error": "limit must be an integer"} / {"error": "limit must be >= 1"} | limit 不對 |
| 429 | {"error_code": "ERR429", "message": "User rate limit exceeded"} | 每分鐘超過 100 次請求 |
200 與 [],意思是「未涵蓋」,不是「沒有排定的事件」。start/end 時,沒有日期的事件會被丟掉;有設 max_priority 時,沒有優先級的事件會被丟掉。real 在公布後才會填入。