API WebSocket e REST Binance
Trasmetti i dati di mercato Binance (trade, kline, ticker, partial book depth, diff depth) e pilota l'API REST firmata da un unico componente tipizzato.
Trasmetti i dati di mercato Binance (trade, kline, ticker, partial book depth, diff depth) e pilota l'API REST firmata da un unico componente tipizzato.
WebSocket Market Streams più accesso REST_API per il trading spot. Si abbina a TsgcWebSocketClient per il trasporto e firma i payload con HMAC-SHA256 utilizzando ApiKey/ApiSecret.
TsgcWSAPI_Binance
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
Collega un TsgcWebSocketClient al componente API, imposta Binance.ApiKey/ApiSecret se ti servono canali firmati, poi chiama 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;
// stream di mercato pubblici
Binance.SubscribeTicker('bnbbtc');
Binance.SubscribeKLine('bnbbtc', bci5m);
Binance.SubscribeDiffDepth('bnbbtc');
// chiamata REST_API (firmata)
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");
Sia i WebSocket Market Streams sia l'API REST firmata sono esposti dallo stesso componente.
SubscribeAggregateTrades, SubscribeTrades, SubscribeKLine, SubscribeTicker, SubscribeAllMarketTickers, SubscribePartialBookDepth e SubscribeDiffDepth coprono l'intero catalogo di stream pubblici di Binance.
Binance.REST_API espone l'intera superficie REST spot: GetAccountInformation, Get24hrTicker, GetKLines, GetOrderBook, GetOpenOrders, WalletWithdraw, GetWalletDepositHistory — oltre 40 metodi tipizzati.
Attiva Binance.BinanceUS per l'endpoint US e Binance.TestNet per la sandbox. Il componente cambia entrambi gli URL di base WebSocket e REST.
Imposta Binance.ApiKey e Binance.ApiSecret — il componente calcola la firma HMAC-SHA256 richiesta da Binance per gli endpoint REST firmati e gli User Data stream.
Usa StartUserDataStream per ottenere una listenKey, poi sottoscrivila per ricevere aggiornamenti in tempo reale di account, ordini e saldi. KeepAliveUserDataStream mantiene attiva la chiave.
Per i futures USDT/COIN-margined usa il componente affine TsgcWSAPI_Binance_Futures — stesso pattern con FuturesContracts che seleziona bfcUSDT o bfcCOIN.
Fonti autorevoli per le API implementate da questo componente.
Accedi al riferimento del componente, scarica il progetto demo pronto all'uso e ottieni la versione di prova.
| Guida online — API_Binance Riferimento completo di proprietà, metodi ed eventi per questo componente. | Apri | |
| Progetto demo — Demos\05.Crypto\01.Binance Progetto di esempio pronto all'uso. Incluso nel pacchetto sgcWebSockets — scarica la versione di prova qui sotto. | Apri | |
| Documento tecnico (PDF) Funzionalità, guida rapida, esempi di codice per Delphi, C++ Builder e .NET e riferimenti delle fonti primarie — solo per questo componente. | Apri | |
| Manuale utente (PDF) Manuale completo che copre ogni componente della libreria. | Apri |