거래소 웹소켓/체결 스트림
체결 스트림
trade_{symbol} 채널을 구독하면 실시간 체결 내역을 스트림으로 수신합니다. 인증 없이 사용할 수 있는 공개 채널입니다.
WS
wss://api.inexcoin.com/open-api/ws구독 메시지
typestring필수
고정값 subscribe.
channelstring필수
구독할 채널명. trade_{symbol}.
응답 필드
marketstring
마켓 코드
tradesarray
체결 내역 배열
trades[].pricestring
체결 가격
trades[].volumestring
체결 수량
trades[].trend_sideenum
BUY 또는 SELL
trades[].timestring
체결 시각
{
"market": "BTC-KRW",
"trades": [
{
"price": "158420000",
"volume": "0.0042",
"trend_side": "BUY",
"time": "2026-07-28T11:32:00+09:00"
}
]
}
구독 예제
import { useEffect, useRef, useState } from "react";
export function useTradeStream(symbol: string) {
const [trades, setTrades] = useState([]);
const ws = useRef<WebSocket>();
useEffect(() => {
ws.current = new WebSocket("wss://api.inexcoin.com/open-api/ws");
ws.current.onopen = () => ws.current?.send(JSON.stringify({
type: "subscribe",
channel: `trade_${symbol}`
}));
ws.current.onmessage = (e) => {
const data = JSON.parse(e.data);
setTrades(data.trades);
};
return () => ws.current?.close();
}, [symbol]);
return trades;
}
NOTE
연결이 끊어지면 지수 백오프로 재연결한 뒤 구독 메시지를 다시 전송하세요. 구독 상태는 연결마다 새로 설정해야 합니다.