Delphi XTB API Client

From sgcWebSockets 2022.7.0 XTB WebSocket API is supported, XTB provides access to over 2100 financial markets including FX, indices, shares, commodities and more.


The WebSocket protocol allows 2 types of requests: Streaming commands (receive live updates) and Retrieve Trading Data (send a request to server retrieving some information).

You can configure the following properties in the XTB property.

  • User: the username that identifies the connection.
  • Password: it's the secret value of the user.
  • Demo: if enabled, will connect to the XTB Demo account (disabled by default).


When the client successfully connects to XTB servers, the event OnXTBConnect is fired. If there is any error while trying to connect, the event OnXTBError will be fired with the error details.

After the event OnXTBConnect is fired, then you can start to send and receive messages from XTB servers.

oClient := TsgcWebSocketClient.Create(nil);
oXTB := TsgcWSAPI_XTB.Create(nil);
oXTB.Client := oClient;
oXTB.XTB.User := 'user_0001';
oXTB.XTB.Password := 'secret_0001';
oClient.Active := True;

procedure OnXTBConnect(Sender: TObject; const aStreamSessionId: string);
  DoLog('#XTB Connected');

procedure OnXTBError(Sender: TObject; aCode, aDescription, aRawMessage: string);
  DoLog('#error: ' + aDescription);

Find below a compiled demo for Windows to test the XTB Client Features.

File Name: sgcXTB
File Size: 3 mb
Download File
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Binance Wallet API
sgcWebSockets 2022.6

Related Posts