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.

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, 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.

Ready to Trade on Binance?

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