Oracle v1 WebSocket API (Deprecated)
Deprecated
Oracle v1 は非推奨(Deprecated)です。このアーカイブは既存の連携向けに旧 API 仕様を保存したもので、旧エンドポイントの稼働を保証するものではありません。新規連携には Oracle v2 を使用してください。旧ソースコードは v1 ブランチ に保存されています。
Oracle server は、ライブ source tick、集計価格更新、finalized source tick bucket を受け取るための読み取り専用 WebSocket エンドポイントを提供します。
本番 WebSocket URL:
wss://api.coinpost.ai/oracle/ws/pricesupstream endpoint path:
GET /ws/prices認証方式
WebSocket upgrade の認証は Oracle server のルールに従います。auth.enabled または cp_auth.enabled が true の場合、API key を Bearer token として送信します。
Authorization: Bearer <api_key>カスタム WebSocket ヘッダーを設定できないブラウザクライアントは、WebSocket URL に token を渡せます。
wss://api.coinpost.ai/oracle/ws/prices?token=<api_key>
wss://api.coinpost.ai/oracle/ws/prices?access_token=<api_key>Query token 認証は price WebSocket endpoint でのみ受け付けます。
REST API の認証方式は REST operation ページを参照してください。
Client Messages
Client message は JSON です。未知のフィールドは無視されます。
Subscribe
{
"type": "subscribe",
"id": "btc-live",
"symbols": ["BTC"],
"channels": ["aggregate", "sources", "ticks"],
"sources": ["bitbank", "binance_japan", "coinbase"],
"include_snapshot": true
}フィールド:
id: 任意の subscription ID。Server はsubscription_idとして同じ値を返します。symbols: 必須。canonical symbol のリストです。channels: 任意のリストです。デフォルトは["aggregate", "sources"]です。sources: 任意の source filter です。省略するか空リストを渡すと、すべての source が対象になります。include_snapshot: 任意の boolean です。true の場合、server は最新状態をすぐに送信します。
Channels:
aggregate:snapshotaggregate data とaggregate_updatemessage を受け取ります。sources:snapshotsource data とsource_updatemessage を受け取ります。ticks: finalizedtickmessage を受け取ります。
Unsubscribe
{
"type": "unsubscribe",
"id": "btc-live"
}id を省略した場合、default subscription が削除されます。
Ping
{
"type": "ping",
"ts": "2026-06-10T06:00:00Z"
}Response:
{
"type": "pong",
"ts": "2026-06-10T06:00:00Z"
}Server Messages
Snapshot
include_snapshot が true の subscribe 後に送信されます。sources は source name から最新 source tick への map です。
{
"type": "snapshot",
"subscription_id": "btc-live",
"symbol": "BTC",
"asset_id": "d388491f-2ee0-337f-bad1-fd8f4444e076",
"tick_interval": "1m0s",
"aggregate": {
"source": "aggregated",
"selected_source": "bitbank",
"selected_pair": "btc_jpy",
"price_usd": "61363.4557105392479143",
"price_jpy": "9839303",
"tick_start": "2026-06-10T15:01:00+09:00",
"tick_interval": "1m0s",
"method": "source_vote",
"vote_band_pct": "0.003",
"vote_sources": ["bitbank", "bitflyer", "coinbase"],
"rejected_sources": ["binance_japan"],
"updated_at": "2026-06-10T15:01:24.347954002+09:00"
},
"sources": {
"bitbank": {
"symbol": "BTC",
"asset_id": "d388491f-2ee0-337f-bad1-fd8f4444e076",
"source": "bitbank",
"pair": "btc_jpy",
"tick_start": "2026-06-10T15:01:00+09:00",
"tick_interval": "1m0s",
"native_price": "9839303",
"native_currency": "JPY",
"price_jpy": "9839303",
"price_usd": "61363.4557105392479143",
"open": "9839303",
"high": "9839303",
"low": "9839303",
"close": "9839303",
"bid": "9837946",
"ask": "9837947",
"source_timestamp": "2026-06-10T15:01:10.046+09:00",
"received_at": "2026-06-10T15:01:11.420015171+09:00",
"transport": "websocket",
"sample_count": 12
}
}
}Source Update
channels に sources が含まれる場合に送信されます。これは公開 API の中で最も低遅延な取引所 source tick event です。
{
"type": "source_update",
"subscription_id": "btc-live",
"symbol": "BTC",
"asset_id": "d388491f-2ee0-337f-bad1-fd8f4444e076",
"source": "bitbank",
"pair": "btc_jpy",
"tick_start": "2026-06-10T15:01:00+09:00",
"tick_interval": "1m0s",
"native_price": "9839303",
"native_currency": "JPY",
"price_jpy": "9839303",
"price_usd": "61363.4557105392479143",
"open": "9839303",
"high": "9839303",
"low": "9839303",
"close": "9839303",
"bid": "9837946",
"ask": "9837947",
"source_timestamp": "2026-06-10T15:01:10.046+09:00",
"received_at": "2026-06-10T15:01:11.420015171+09:00",
"transport": "websocket",
"sample_count": 12,
"updated_at": "2026-06-10T15:01:11.421000000+09:00"
}フィールド補足:
native_price: source quote currency で観測した最新価格です。price_usd/price_jpy: 変換できる場合の正規化価格です。open,high,low,close: 現在のtick_startに対応する source tick bucket の値です。bid/ask: source ticker が提供する場合の best bid と best ask です。sample_count: 現在の bucket に畳み込まれた source message 数です。source_timestamp: 取引所または upstream source が報告した時刻です。received_at: worker がローカルで受信した時刻です。
Bid と ask の提供状況:
| Source | Bid/ask |
|---|---|
bitbank | Yes |
binance_japan | Yes |
bitflyer | Yes |
coinbase | Yes |
gmo_coin | Yes |
coincheck | No, current collector uses trades |
coingecko | No, current collector uses simple price |
これらは ticker level の best bid と best ask です。full order book ではありません。
Aggregate Update
channels に aggregate が含まれる場合に送信されます。Worker は各 source update 後に現在の aggregate を再計算します。
{
"type": "aggregate_update",
"subscription_id": "btc-live",
"symbol": "BTC",
"asset_id": "d388491f-2ee0-337f-bad1-fd8f4444e076",
"source": "bitbank",
"tick_start": "2026-06-10T15:01:00+09:00",
"tick_interval": "1m0s",
"aggregate": {
"source": "aggregated",
"selected_source": "bitbank",
"selected_pair": "btc_jpy",
"price_usd": "61363.4557105392479143",
"price_jpy": "9839303",
"tick_start": "2026-06-10T15:01:00+09:00",
"tick_interval": "1m0s",
"method": "source_vote",
"vote_band_pct": "0.003",
"vote_sources": ["bitbank", "bitflyer", "coinbase"],
"rejected_sources": ["binance_japan"],
"updated_at": "2026-06-10T15:01:24.347954002+09:00"
},
"updated_at": "2026-06-10T15:01:24.347954002+09:00"
}Tick
channels に ticks が含まれ、tick bucket が finalized になったときに送信されます。
{
"type": "tick",
"subscription_id": "btc-live",
"symbol": "BTC",
"asset_id": "d388491f-2ee0-337f-bad1-fd8f4444e076",
"tick_start": "2026-06-10T15:01:00+09:00",
"tick_interval": "1m0s",
"aggregate": {
"source": "aggregated",
"selected_source": "bitbank",
"selected_pair": "btc_jpy",
"price_usd": "61363.4557105392479143",
"price_jpy": "9839303",
"method": "source_vote",
"vote_sources": ["bitbank", "bitflyer", "coinbase"],
"rejected_sources": ["binance_japan"]
},
"sources": {
"bitbank": {
"pair": "btc_jpy",
"native_price": "9839303",
"native_currency": "JPY",
"price_jpy": "9839303",
"price_usd": "61363.4557105392479143",
"open": "9839303",
"high": "9839303",
"low": "9839303",
"close": "9839303",
"bid": "9837946",
"ask": "9837947",
"transport": "websocket",
"sample_count": 12
}
},
"updated_at": "2026-06-10T15:02:02.000000000+09:00"
}Example Client
const ws = new WebSocket("wss://api.coinpost.ai/oracle/ws/prices");
ws.addEventListener("open", () => {
ws.send(JSON.stringify({
type: "subscribe",
id: "btc-live",
symbols: ["BTC"],
channels: ["aggregate", "sources"],
include_snapshot: true
}));
});
ws.addEventListener("message", (event) => {
const msg = JSON.parse(event.data);
if (msg.type === "source_update") {
console.log(msg.source, msg.bid, msg.ask, msg.native_price);
}
});運用上の注意
GET /prices/sources?symbol=BTCは stale な source tick を除外します。本番 REST Base URL ではhttps://api.coinpost.ai/oracle/prices/sources?symbol=BTCを呼び出します。- WebSocket
source_updateはライブ更新が到着した時点で送信されます。 source_updateには現在 bucket の OHLC 値が含まれます。finalized historical candle ではありません。- このエンドポイントは full order book depth を提供しません。完全な depth が必要な場合は、取引所の order book stream を使ってください。
