即時串流
透過 WebSocket 建立長連線,接收即時事件。
連線
// 以支援自訂 header 的 WebSocket client 為例
const ws = new WebSocket("wss://api.blockchainsecurity.asia/v1/stream", {
headers: { "X-API-Key": "ak_live_YOUR_KEY" },
});
ws.on("message", (data) => {
console.log("event:", data.toString());
});import websocket
ws = websocket.create_connection(
"wss://api.blockchainsecurity.asia/v1/stream",
header=["X-API-Key: ak_live_YOUR_KEY"],
)
print(ws.recv()) # welcome 訊息連線後的訊息
{ "type": "welcome", "key": "ak_live_3f9a2c7b" }保持連線
Last updated
Was this helpful?

