XTB WebSocket API
Connect to XTB xStation 5 over WebSocket for forex/CFD prices, candle streams, balance and trade updates — with a typed Delphi component.
Connect to XTB xStation 5 over WebSocket for forex/CFD prices, candle streams, balance and trade updates — with a typed Delphi component.
XTB xStation 5 WebSocket client — login/logout, GetTickPrices, GetCandles, plus the streaming side for getBalance / getKeepAlive / getTradeStatus.
TsgcWSAPI_XTB
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
Pair the component with a TsgcWebSocketClient targeting xStation, log in, then call GetTickPrices / GetCandles or subscribe to the streaming endpoints.
uses
sgcWebSocket, sgcWebSocket_API_XTB;
var
WSClient: TsgcWebSocketClient;
XTB: TsgcWSAPI_XTB;
begin
WSClient := TsgcWebSocketClient.Create(nil);
XTB := TsgcWSAPI_XTB.Create(nil);
XTB.Client := WSClient;
WSClient.Active := True;
XTB.Login('user-id', 'password');
XTB.GetTickPrices(['EURUSD', 'USDJPY'], 0);
XTB.GetCandles('EURUSD');
end;
// uses: sgcWebSocket, sgcWebSocket_API_XTB
TsgcWebSocketClient *WSClient = new TsgcWebSocketClient(this);
TsgcWSAPI_XTB *XTB = new TsgcWSAPI_XTB(this);
XTB->Client = WSClient;
WSClient->Active = true;
XTB->Login("user-id", "password");
XTB->GetCandles("EURUSD");
Session-based JSON RPC over WebSocket with separate sync and streaming endpoints — both wrapped in typed Delphi methods.
xStation uses request/response JSON RPC over a session-anchored WebSocket. Login opens the session and stores the streamSessionId for the streaming endpoint.
Typed methods cover the sync side: GetAllSymbols, GetCalendar, GetCandles, GetCommissionDef, GetMarginLevel, GetServerTime, GetUserData and more.
Hook the streaming endpoint via SubscribeTickPrices, SubscribeCandles, SubscribeBalance, SubscribeKeepAlive, SubscribeNews, SubscribeTradeStatus.
TradeTransaction places, modifies and closes orders over the sync endpoint — TradeTransactionStatus polls the resulting order's state.
Point the underlying TsgcWebSocketClient at wss://ws.xtb.com/demo or wss://ws.xtb.com/real — the wire protocol is identical.
XTB drops idle sessions after ~30 minutes — bind the underlying client's HeartBeat to ping so the session stays alive between sparse calls.
Authoritative sources for the APIs this component implements.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — API_XTB Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\05.Crypto\13.XTB Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below. | Open | |
| Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |