基差歷史(小時級)
單一幣種的小時基差序列,依交易所提供,並附跨交易所彙總值(中位數、平均值、OI 加權)。
/api/sd/basis/history請求
查詢參數
| 名稱 | 型別 | 必填 | 預設值 | 可用值 | 說明 |
|---|---|---|---|---|---|
| coin | string | 必填 | — | — | 幣種代號,不分大小寫(例如 `BTC`)。缺少或格式錯誤時回傳 400。 範例: BTC |
| kind | string | 選填 | perp | perp, spot_perp | `perp`:標記價格相對於同一交易所的指數價格。`spot_perp`:永續合約價格相對於同一交易所的現貨價格。 |
| range | string | 選填 | 24h | 24h, 7d, 30d | 回溯範圍,每小時一個資料點。 |
| exchange | string | 選填 | — | — | 單一交易所 ID。預設:所有交易所。未知的 ID 會回傳 400。 |
請求範例
curl -s "https://www.coinboss.com/api/sd/basis/history?coin=BTC"回應欄位
欄位表由真實回應產生,因此列出的正是端點實際回傳的內容。路徑中的 a[] 代表陣列元素,{*} 代表以動態名稱(例如幣種或交易所)為鍵的物件。
| 欄位 | 型別 | 單位 | 說明 |
|---|---|---|---|
| success | boolean | — | 請求成功時為 true。失敗時回應內容為 `{ success: false, code, error, request_id }`。 |
| schema | string | — | 此回應的結構描述 ID。只有在既有欄位的意義或型別改變時才會變更。 |
| now | number | ms | 建立回應時的伺服器時間。 |
| coin | string | — | 幣種代號(大寫)。 |
| kind | string | — | `perp` 或 `spot_perp`。 |
| range | string | — | 實際套用的回溯範圍。 |
| interval | string | — | 序列資料點的間隔。 |
| exchange | string|null | — | 交易所 ID(小寫)。 |
| aggregate | array | — | 此區段的跨交易所彙總值。 |
| aggregate[] | object | — | 此區段的跨交易所彙總值。 |
| aggregate[].t | number | ms | 時間區間的起始時間。 |
| aggregate[].median_pct | number | % | 每家交易所取一個主力合約所得的基差中位數。 |
| aggregate[].mean_pct | number | % | 與中位數相同集合的簡單平均值。 |
| aggregate[].oi_weighted_pct | number | % | 以持倉量加權的基差;沒有 OI 權重的資料列不計入。 |
| aggregate[].n_exchanges | number | — | 計入彙總值的交易所。 |
| series | array | — | 每家交易所一條序列。 |
| series[] | object | — | 每家交易所一條序列。 |
| series[].exchange | string | — | 交易所 ID(小寫)。 |
| series[].symbol | string | — | CoinBoss 儲存格式的合約代號。 |
| series[].primary | boolean | — | 在中位數與平均值中代表其交易所的合約為 true。 |
| series[].in_aggregate | boolean | — | 該列通過納入規則時為 true。 |
| series[].points | array | — | `[hour start in ms, basis in %]` 數對,由舊到新排列。 |
| series[].points[] | array | — | `[hour start in ms, basis in %]` 數對,由舊到新排列。 |
| series[].points[][] | number | — | `[hour start in ms, basis in %]` 數對,由舊到新排列。 |
| history | object | — | 請求範圍中有多少資料可用。 |
| history.requested_from | number | ms | 請求範圍的起始時間。 |
| history.available_from | number | ms | 已儲存的第一個小時。 |
| history.available_to | number | ms | 已儲存的最後一個小時。 |
| history.n_hours | number | — | 範圍內可用的小時數。 |
| history.expected_hours | number | — | 範圍完整時應有的小時數。 |
| history.complete | boolean | — | 請求範圍內的每個小時皆已儲存時為 true。 |
| coverage | object | — | 數字中納入與未納入的內容。與其他來源比較合計值之前,請先比對這一項。 |
| coverage.included_exchanges | array | — | 新鮮資料已被納入的來源。 |
| coverage.included_exchanges[] | string | — | 新鮮資料已被納入的來源。 |
| coverage.unavailable | array | — | 無法納入的來源,各附原因。它們絕不會以 0 計入。 |
| coverage.unavailable[] | object | — | 無法納入的來源,各附原因。它們絕不會以 0 計入。 |
| coverage.unavailable[].exchange | string | — | 交易所 ID(小寫)。 |
| coverage.unavailable[].reason | string | — | 機器可讀的原因代碼。 |
| coverage.unavailable[].detail | string | — | 供人閱讀的原因說明。 |
| coverage.stale_excluded | array | — | 因最近一次更新超出新鮮視窗而被排除的資料列。 在產生此表所用的樣本中為空 |
| method | object | — | 此回應所用公式的純文字說明,每個欄位一項。 |
| method.series.points | string | — | `series.points` 的公式說明,純文字。 |
| method.aggregate.median_pct | string | — | `aggregate.median_pct` 的公式說明,純文字。 |
| method.aggregate.oi_weighted_pct | string | — | `aggregate.oi_weighted_pct` 的公式說明,純文字。 |
| method.interval | string | — | `interval` 的公式說明,純文字。 |
| meta | object | — | 此回應的資料歷程與新鮮度。 |
| meta.schema | string | — | 此回應的結構描述 ID。只有在既有欄位的意義或型別改變時才會變更。 |
| meta.source | array | — | 資料採集所用的上游公開端點。 |
| meta.source[] | object | — | 資料採集所用的上游公開端點。 |
| meta.source[].exchange | string | — | 交易所 ID(小寫)。 |
| meta.source[].endpoint | string | — | 採集器讀取的來源公開端點(僅供說明資料歷程;用戶端不會直接呼叫它)。 |
| meta.observed_at | null | — | 來源為該資料提供的時間戳記。 |
| meta.received_at | number | ms | CoinBoss 採集器收到資料的時間。 |
| meta.fetched_at | number | ms | 此回應組裝完成的時間。 |
| meta.window | string | — | 數字涵蓋的時間視窗。 |
| meta.quality | string | — | FRESH、PARTIAL、STALE、BROKEN 或 UNAVAILABLE,依資料時間戳記與覆蓋範圍判定。 |
| meta.is_stale | boolean | — | 資料已超出其新鮮視窗時為 true。 |
| meta.cache_ttl_s | number | s | 此回應的快取存活時間。 |
| meta.fallback | string | — | 採集器或來源發生故障時,此端點回傳的內容。 |
產生於 2026-11-11 23:00 UTC,依據 3 筆真實回應。
回應範例
/api/sd/basis/history?coin=BTC · 真實回應,擷取於 2026-11-13 04:02:46 UTC。 較長的陣列與對應表已截短顯示:series 原有 20 個項目; aggregate 原有 25 個項目; meta.source 原有 20 個項目; series[].points 原有 25 個項目; coverage.included_exchanges 原有 20 個項目。
- "success"true
- "schema""coinboss.sd.basis/1"
- "now"1794542288014
- "coin""BTC"
- "kind""perp"
- "range""24h"
- "interval""1h"
- "exchange"null
- "aggregate"
- "series"
- "history"
- "requested_from"1794452400000
- "available_from"1794452400000
- "available_to"1794538800000
- "n_hours"25
- "expected_hours"24
- "complete"true
- "coverage"
- "included_exchanges"
- "unavailable"
- "stale_excluded"
- "method"
- "series.points""[hour_ts, (mark_price - index_price) / index_price * 100] from the first collector round after each full hour; hours where the two timestamps were more than 60 …"
- "aggregate.median_pct""median over one primary contract per exchange in that hour; excluded: |value| > 10, contracts with no trade in 24 h, exchanges whose index is not a comparable i…"
- "aggregate.oi_weighted_pct""sum(value * oi_usd) / sum(oi_usd) over all included contracts that have an OI snapshot for the same hour (oi_history / sd_contract_hourly, single-sided); null w…"
- "interval""fixed 1 h buckets, no interpolation; missing hours are simply absent"
- "meta"
- "schema""coinboss.sd.basis/1"
- "source"
- "observed_at"null
- "received_at"1794538827406
- "fetched_at"1794542288014
- "window""24h"
- "quality""FRESH"
- "is_stale"false
- "cache_ttl_s"300
- "fallback""history is served as stored; hours without a snapshot are absent, never interpolated"
已驗證的樣本
除了上方的範例之外,探針還會以下列參數呼叫此端點,並在每次呼叫時檢查結構描述。
| 參數 | HTTP | 延遲 | 結果 |
|---|---|---|---|
| coin=ETH&kind=spot_perp | 200 | 41 ms | 通過 FRESH |
| coin=BTC&exchange=binance | 200 | 32 ms | 通過 FRESH |
| coin=BTC&range=1y | 400 | 1 ms | 通過 回傳預期的錯誤 |
檢查於 2026-11-13 03:58:08 UTC
詳細資訊
- 身分驗證
- 無。公開端點。
- 速率限制
- 每個 IP 每分鐘 1200 次請求
- 伺服器快取
- 5m
- 邊緣微快取
- 10s
- 更新頻率
- 採集器每 60 秒執行一輪;資料列在 180 秒內視為新鮮。歷史資料由小時快照構成。
- 時間視窗
- 24h / 7d / 30d,小時區間。
- 資料來源
- 21 家衍生品交易所公布的標記價格、指數價格與最新成交價,加上同一交易所的現貨價格,由 CoinBoss 採集並儲存(sd_px_latest、sd_px_hourly)。
- 交易所覆蓋範圍
- 21 家交易所。未公布指數價格或標記價格的交易所列於 `coverage.unavailable`;兩端價格的時間相差超過 60 秒的資料列回傳 `null`。未計入彙總值的資料列列於 `coverage.excluded_from_aggregate`,並附原因。
- 分頁
- 不分頁;資料點數量由 `range` 決定。
- 排序
- 時間升冪。
- 單位
- All basis values in percent. Prices in the quote currency of the contract (USDT / USDC / USD). `oi_usd` single-sided.
- 計算方法
- Each point is the snapshot taken in the first ten minutes of the hour. The OI weight of a historical hour is the open interest recorded in that hour; without it `oi_weighted_pct` is `null`.
- 時間戳記
- Unix epoch 毫秒(UTC),除非欄位說明另有註明
- 回應格式
- json
- 穩定性
- 穩定版
- 上線時間
- 2026-11-11
即時狀態
採集始於 2026-11-11。回應會回報 `history.available_from`、`n_hours` 與 `expected_hours` 的對照,以及 `complete`;沒有資料的小時會直接留空,不做內插。
近 30 天可用率
408 次檢查中有 100% 通過
錯誤
所有端點的失敗回應都採用同一種結構。完整清單請見錯誤頁面。 錯誤與速率限制 →
| 錯誤碼 | HTTP | 意義 | 處理方式 |
|---|---|---|---|
| INVALID_PARAM | 400 | 缺少必填參數,或某個值不被接受。已知時,`param` 會指出是哪個參數。 | 請勿原樣重試;請修正請求。 |
| UNAUTHORIZED | 401 | 已送出 `CB-API-KEY` 標頭,但金鑰未知或已撤銷。公開資料不需要金鑰——請移除該標頭或改用有效的金鑰。 | 請勿原樣重試。 |
| FORBIDDEN | 403 | 此路由不屬於公開 API(內部或僅限帳戶使用)。 | 請勿重試。 |
| NOT_FOUND | 404 | 未知的路由,或所請求的幣種/交易所/基金不存在。 | 請勿重試;請對照目錄檢查路徑與識別碼。 |
| RATE_LIMITED | 429 | 請求數超過每分鐘上限。`Retry-After` 會指出需等待的秒數。 | 等待 `Retry-After` 指定的時間後,再以退避策略重試。 |
| INTERNAL | 500 | 非預期的伺服器錯誤。訊息刻意保持籠統;回報時請附上 `request_id`。 | 幾秒後重試一次;若問題持續,請附上請求 ID 回報。 |
| UPSTREAM_FAILED | 503 | 此端點背後的資料來源未及時回應。不會以過期或替代的數字代替回傳。 | 以退避策略重試;並查看狀態頁面。 |
| UNAVAILABLE | 501 / 503 | 資料集暫時尚未就緒(快取預熱中),或此端點目前尚無合法的公開來源。 | 稍後重試;目錄會標示出設計上即無法使用的端點。 |
| REQUEST_FAILED | 200 | 部分舊版端點會以 HTTP 200 回應但帶有 `success: false`。請務必檢查 `success`,而不只是 HTTP 狀態碼。 | 視訊息而定;請當作失敗的請求處理。 |
試用
/api/sd/basis/history部分可用string — Coin symbol, case-insensitive (for example `BTC`). Missing or malformed values return 400.
string · 預設 perp — `perp`: mark price against the index price of the same exchange. `spot_perp`: perpetual price against the spot price of the same exchange.
string · 預設 24h — Look-back range, one point per hour.
string — One exchange id. Default: all exchanges. An unknown id returns 400.
https://www.coinboss.com/api/sd/basis/history?coin=BTC此分類的其他端點
- 合約基差(所有交易所) /api/sd/basis
- 基差歷史(小時級) /api/sd/basis/history
- 依基差排行的幣種 /api/sd/basis/rank
- 期現基差清單 /api/derivatives/basis
- Coinbase 與 Kraken 的 BTC 每日價差 /api/p3/cb-kr-spread
- Coinbase 比特幣溢價指數 /api/p3/coinbase-premium
- 永續合約溢價指數清單 /api/p3/premium-index
- 單一幣種的溢價指數歷史 /api/p3/premium-index/history
- 溢價指數 K 線 /api/p3/premium-index/klines
- USDT 場外價格相對法幣匯率的溢價 /api/usdt-premium
- 完整期現基差清單 /api/basis/list