XTB xStation WebSocket API — sgcWebSockets | eSeGeCe

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.

TsgcWSAPI_XTB

XTB xStation 5 WebSocket client — login/logout, GetTickPrices, GetCandles, plus the streaming side for getBalance / getKeepAlive / getTradeStatus.

Component class

TsgcWSAPI_XTB

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Standard / Professional / Enterprise

Drop the component, set keys, subscribe

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");

What's inside

Session-based JSON RPC over WebSocket with separate sync and streaming endpoints — both wrapped in typed Delphi methods.

JSON RPC sessions

xStation uses request/response JSON RPC over a session-anchored WebSocket. Login opens the session and stores the streamSessionId for the streaming endpoint.

Sync endpoint

Typed methods cover the sync side: GetAllSymbols, GetCalendar, GetCandles, GetCommissionDef, GetMarginLevel, GetServerTime, GetUserData and more.

Streaming endpoint

Hook the streaming endpoint via SubscribeTickPrices, SubscribeCandles, SubscribeBalance, SubscribeKeepAlive, SubscribeNews, SubscribeTradeStatus.

Trade transactions

TradeTransaction places, modifies and closes orders over the sync endpoint — TradeTransactionStatus polls the resulting order's state.

Demo or real

Point the underlying TsgcWebSocketClient at wss://ws.xtb.com/demo or wss://ws.xtb.com/real — the wire protocol is identical.

Heartbeat / session

XTB drops idle sessions after ~30 minutes — bind the underlying client's HeartBeat to ping so the session stays alive between sparse calls.

Specifications & references

Authoritative sources for the APIs this component implements.

Documentation & Demos

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.
Demo Project — Demos\05.Crypto\13.XTB Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only.
User Manual (PDF) Comprehensive manual covering every component in the library.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Ready to Trade with XTB?

Download the free trial and integrate XTB xStation streaming into your Delphi applications.