Binance WebSocket & REST API

Stream Binance market data (trades, klines, ticker, partial book depth, diff depth) and drive the signed REST API from a single typed component.

Quick answer: TsgcWSAPI_Binance is the sgcWebSockets component that connects Delphi and C++ Builder apps to Binance. It subscribes to the WebSocket Market Streams and calls the signed spot REST API, all from one typed object.

TsgcWSAPI_Binance

WebSocket Market Streams plus REST_API access for spot trading. Pairs with TsgcWebSocketClient for the transport and signs payloads with HMAC-SHA256 against your ApiKey/ApiSecret.

Component class

TsgcWSAPI_Binance

Protocol

Binance Spot API

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Standard / Professional / Enterprise

Drop the component, set keys, subscribe

Plug a TsgcWebSocketClient into the API component, set Binance.ApiKey/ApiSecret if you need signed channels, then call SubscribeTicker / SubscribeKLine / SubscribeDiffDepth.

uses
  sgcWebSocket, sgcWebSocket_API_Binance;

var
  WSClient: TsgcWebSocketClient;
  Binance: TsgcWSAPI_Binance;
begin
  WSClient := TsgcWebSocketClient.Create(nil);

  Binance := TsgcWSAPI_Binance.Create(nil);
  Binance.Client := WSClient;
  Binance.Binance.ApiKey    := 'your-api-key';
  Binance.Binance.ApiSecret := 'your-api-secret';

  WSClient.Active := True;

  // public market streams
  Binance.SubscribeTicker('bnbbtc');
  Binance.SubscribeKLine('bnbbtc', bci5m);
  Binance.SubscribeDiffDepth('bnbbtc');

  // REST_API call (signed)
  ShowMessage(Binance.REST_API.GetAccountInformation);
end;
// uses: sgcWebSocket, sgcWebSocket_API_Binance
TsgcWebSocketClient *WSClient = new TsgcWebSocketClient(this);

TsgcWSAPI_Binance *Binance = new TsgcWSAPI_Binance(this);
Binance->Client = WSClient;
Binance->Binance->ApiKey    = "your-api-key";
Binance->Binance->ApiSecret = "your-api-secret";

WSClient->Active = true;

Binance->SubscribeTicker("bnbbtc");
Binance->SubscribeKLine("bnbbtc", bci5m);
Binance->SubscribeDiffDepth("bnbbtc");

ShowMessage(Binance->REST_API->GetAccountInformation());
using esegece.sgcWebSockets;

var WSClient = new TsgcWebSocketClient();
var Binance  = new TsgcWSAPI_Binance();
Binance.Client = WSClient;
Binance.Binance.ApiKey    = "your-api-key";
Binance.Binance.ApiSecret = "your-api-secret";

WSClient.Active = true;

Binance.SubscribeTicker("bnbbtc");
Binance.SubscribeKLine("bnbbtc", TBinanceCryptoInterval.bci5m);
Binance.SubscribeDiffDepth("bnbbtc");

What's inside

Both the WebSocket Market Streams and the signed REST API are exposed by the same component.

Market data streams

SubscribeAggregateTrades, SubscribeTrades, SubscribeKLine, SubscribeTicker, SubscribeAllMarketTickers, SubscribePartialBookDepth and SubscribeDiffDepth cover the full Binance public stream catalog.

Signed REST API

Binance.REST_API exposes the full spot REST surface: GetAccountInformation, Get24hrTicker, GetKLines, GetOrderBook, GetOpenOrders, WalletWithdraw, GetWalletDepositHistory — over 40 typed methods.

HTTP status & rate limit headers

New in 2026.12: REST_API.LastResponseCode and REST_API.LastResponseHeaders give the HTTP status and the response headers (raw Name: value lines) of every REST call, and the OnHTTPAPIResponse event fires after every request, on success or error, before the error is raised. Read X-MBX-USED-WEIGHT-1M to stay under the Binance request weight limits. TsgcWSAPI_Binance_Futures works the same way.

Server shutdown & 24 hour reconnect

New in 2026.12: when Binance announces that it will close a connection (serverShutdown), the OnBinanceServerShutdown event tells which connection closes (market or userdata) and when. With Binance.ReconnectOnServerShutdown (default True) the component reconnects that connection at once and replays its subscriptions, while the other connection stays open. Binance.MaxConnectionAge (default 82800 seconds, 23 hours) reconnects before Binance closes every connection after 24 hours. TsgcWSAPI_Binance_Futures works the same way.

Exact decimal amounts

New in 2026.12: the order methods (NewOrder, PlaceLimitOrder, PlaceMarketOrder and the other Place* helpers, NewOCO, order lists and SOR orders) accept prices and quantities as exact decimal text, for example '0.00100000'. The text is sent unchanged, so no float conversion can change the last digit, and invalid text or a negative amount raises an exception before the request is sent. TsgcWSAPI_Binance_Futures has the same overloads, ModifyOrder included.

Persistent REST connection

New in 2026.12: set REST_API.KeepAlive to True (default False) and the component keeps one HTTP/1.1 connection open and reuses it, so an order or a query no longer pays a new TCP and TLS handshake. An idle connection that the server closed is reopened before the request is sent. A POST, PUT, PATCH or DELETE that was already sent is never sent again, only a GET that failed on a closed connection is retried once. Calls on one instance are serialized. TsgcWSAPI_Binance_Futures works the same way.

Spot, Binance.US & TestNet

Toggle Binance.BinanceUS for the US endpoint and Binance.TestNet for the sandbox. The component switches both the WebSocket and REST base URLs.

Authentication

Set Binance.ApiKey and Binance.ApiSecret — the component computes the HMAC-SHA256 signature Binance requires for signed REST endpoints and User Data streams.

User Data Stream

Use StartUserDataStream to obtain a listenKey, then subscribe to it for real-time account, order and balance updates. KeepAliveUserDataStream keeps the key alive.

Futures sibling

For USDT/COIN-margined futures use the sibling component TsgcWSAPI_Binance_Futures — identical pattern with FuturesContracts selecting bfcUSDT or bfcCOIN.

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_Binance Full property, method and event reference for this component.
Demo Project — Demos\05.Crypto\01.Binance 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 .NET and primary-source references — this component only.
User Manual (PDF) Comprehensive manual covering every component in the library.

Frequently asked questions

Common questions about the Binance API component for Delphi and C++ Builder.

Drop a TsgcWebSocketClient and a TsgcWSAPI_Binance component on your form, assign the client to the API component's Client property, set Binance.ApiKey and Binance.ApiSecret if you need signed channels, then set WSClient.Active := True. Once connected you call methods like SubscribeTicker or SubscribeKLine to receive real-time data.
Yes. The same TsgcWSAPI_Binance component exposes the WebSocket Market Streams (trades, klines, ticker, partial and diff book depth) and the signed spot REST API through Binance.REST_API, with over 40 typed methods such as GetAccountInformation, Get24hrTicker and GetOrderBook.
Public market data streams work without credentials. You only need a Binance API key and secret for signed endpoints: the spot REST trading calls and the User Data Stream. Set Binance.ApiKey and Binance.ApiSecret and the component computes the HMAC-SHA256 signature Binance requires.
sgcWebSockets supports Delphi 7 through the latest Delphi 13 Florence, plus the matching C++ Builder versions. The Binance component runs on Windows, macOS, Linux, iOS and Android, and there is a .NET edition with the same API.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €741.30/year.
See All-Access pricing

Ready to Trade on Binance?

Download the free trial and integrate Binance spot, futures and account streams into your Delphi applications.