sgcWebSockets · Technical Document

Bitstamp API

Bitstamp WebSocket client — live order book, trade and ticker streams for every supported instrument.

Overview

Bitstamp is a bitcoin exchange based in Luxembourg. It allows trading between USD currency and bitcoin cryptocurrency. It allows USD, EUR, bitcoin, litecoin, ethereum, ripple or bitcoin cash deposits and withdrawals.

At a glance

Component class
TsgcWSAPI_Bitstamp
Standards / spec
Bitstamp WebSocket API v2
Transports
TCP, TLS
Platforms
Windows, macOS, Linux, iOS, Android
Frameworks
VCL, FireMonkey, Lazarus / FPC, .NET
Edition
Standard / Professional / Enterprise

Features

Technical specification

Standards & specsBitstamp WebSocket API v2
Component classTsgcWSAPI_Bitstamp (unit sgcWebSocket_API_Bitstamp)
FrameworksVCL, FireMonkey, Lazarus / FPC, .NET
PlatformsWindows, macOS, Linux, iOS, Android

Main properties

The principal published / public properties used to configure and drive the component. Consult the online help for the full list.

ClientPublished or public property used to configure or query the component.
OnConnectPublished or public property used to configure or query the component.
OnDisconnectPublished or public property used to configure or query the component.
OnMessagePublished or public property used to configure or query the component.
OnBinaryPublished or public property used to configure or query the component.
OnFragmentedPublished or public property used to configure or query the component.
OnErrorPublished or public property used to configure or query the component.
OnExceptionPublished or public property used to configure or query the component.
OnBitstampHTTPExceptionPublished or public property used to configure or query the component.
BitstampPublished or public property used to configure or query the component.

Main methods

The principal public methods exposed by the component.

SubscribeLiveOrders()Public procedure exposed by the component.
UnSubscribeLiveOrders()Public procedure exposed by the component.
SubscribeLiveOrderBook()Public procedure exposed by the component.
UnSubscribeLiveOrderBook()Public procedure exposed by the component.
SubscribeLiveDetailOrderBook()Public procedure exposed by the component.
UnSubscribeLiveDetailOrderBook()Public procedure exposed by the component.
SubscribeLiveFullOrderBook()Public procedure exposed by the component.
UnSubscribeLiveFullOrderBook()Public procedure exposed by the component.
SubscribeMyOrders()Public procedure exposed by the component.
UnSubscribeMyOrders()Public procedure exposed by the component.

Quick Start

Drop the component on a form, configure the properties below and activate it. The snippet that follows shows the typical Binance | Connect WebSocket API configuration sourced from the online help.

About this scenario. In order to connect to Binance WebSocket API, just create a new Binance API client and attach to TsgcWebSocketClient.

Delphi (VCL / FireMonkey)

oClient := TsgcWebSocketClient.Create(nil);
oBinance := TsgcWSAPI_Binance.Create(nil);
oBinance.Client := oClient;
oClient.Active := True;

C++ Builder

TsgcWebSocketClient *oClient = new TsgcWebSocketClient(NULL);
TsgcWSAPI_Binance *oBinance = new TsgcWSAPI_Binance(NULL);
oBinance->Client = oClient;
oClient->Active = true;

.NET (C#)

TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Binance oBinance = new TsgcWSAPI_Binance();
oBinance.Client = oClient;
oClient.Active = true;

Common scenarios

The following scenarios are lifted verbatim from the online help. Each shows the configuration and method calls needed to drive the component through a specific real-world flow.

1 · Bitmex | Connect WebSocket API

In order to connect to Bitmex WebSocket API, just create a new Bitmex API client and attach to TsgcWebSocketClient.

Delphi (VCL / FireMonkey)
oClient := TsgcWebSocketClient.Create(nil);
oBitmex := TsgcWSAPI_Bitmex.Create(nil);
oBitmex .Client := oClient;
oClient.Active := True;
C++ Builder
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex();
oBitmex->Client = oClient;
oClient->Active = true;
.NET (C#)
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex();
oBitmex.Client = oClient;
oClient.Active = true;

2 · Coinbase | Connect WebSocket API

In order to connect to Coinbase WebSocket API, just create a new Coinbase API client and attach to TsgcWebSocketClient. See below an example:

Delphi (VCL / FireMonkey)
oClient := TsgcWebSocketClient.Create(nil);
oCoinbase := TsgcWSAPI_Coinbase.Create(nil);
oCoinbase.Client := oClient;
oClient.Active := True;
C++ Builder
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Coinbase oCoinbase = new TsgcWSAPI_Coinbase();
oCoinbase->Client = oClient;
oClient->Active = true;
.NET (C#)
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Coinbase oCoinbase = new TsgcWSAPI_Coinbase();
oCoinbase.Client = oClient;
oClient.Active = true;

3 · Kucoin | Connect WebSocket API

In order to connect to Kucoin WebSocket API, just create a new Kucoin API client and attach to TsgcWebSocketClient.

Delphi (VCL / FireMonkey)
oClient := TsgcWebSocketClient.Create(nil);
oKucoin := TsgcWSAPI_Kucoin.Create(nil);
oKucoin.Client := oClient;
oClient.Active := True;
C++ Builder
TsgcWebSocketClient *oClient = new TsgcWebSocketClient();
TsgcWSAPI_Kucoin *oKucoin = new TsgcWSAPI_Kucoin();
oKucoin->Client = oClient;
oClient->Active = true;
.NET (C#)
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Kucoin oKucoin = new TsgcWSAPI_Kucoin();
oKucoin.Client = oClient;
oClient.Active = true;

4 · Kucoin | Futures Connect WebSocket API

In order to connect to Kucoin WebSocket API, just create a new Kucoin API client and attach to TsgcWebSocketClient.

Delphi (VCL / FireMonkey)
oClient := TsgcWebSocketClient.Create(nil);
oKucoin := TsgcWSAPI_Kucoin_Futures.Create(nil);
oKucoin.Client := oClient;
oClient.Active := True;
C++ Builder
TsgcWebSocketClient *oClient = new TsgcWebSocketClient();
</code><code class="delphi">TsgcWSAPI_Kucoin_Futures </code><code class="cpp">*oKucoin = new </code><code class="delphi">TsgcWSAPI_Kucoin_Futures</code><code class="cpp">();
oKucoin->Client = oClient;
oClient->Active = true;
.NET (C#)
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
</code><code class="delphi">TsgcWSAPI_Kucoin_Futures </code><code class="csharp">oKucoin = new </code><code class="delphi">TsgcWSAPI_Kucoin_Futures</code><code class="csharp">();
oKucoin.Client = oClient;
oClient.Active = true;

5 · Binance | Subscribe WebSocket Channel

Binance offers a variety of channels where you can subscribe to get real-time updates of market data, orders... Find below a sample of how to subscribe to a Ticker:

Delphi (VCL / FireMonkey)
oClient := TsgcWebSocketClient.Create(nil);
oBinance := TsgcWSAPI_Binance.Create(nil);
oBinance.Client := oClient;
oBinance.SubscribeTicker('bnbbtc');

procedure OnMessage(Connection: TsgcWSConnection; const aText: string);
begin
// here you will receive the ticker updates
end;
C++ Builder
TsgcWebSocketClient *oClient = new TsgcWebSocketClient(NULL);
TsgcWSAPI_Binance *oBinance = new TsgcWSAPI_Binance(NULL);
oBinance->Client = oClient;
oBinance->SubscribeTicker("bnbbtc");

void OnMessage(TsgcWSConnection *Connection, const string aText)
{
// here you will receive the ticker updates
}
.NET (C#)
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Binance oBinance = new TsgcWSAPI_Binance();
oBinance.Client = oClient;
oBinance.SubscribeTicker("bnbbtc");	

void OnMessage(TsgcWSConnection Connection, const string aText)
{
// here you will receive the ticker updates
}

6 · Bitmex | Subscribe WebSocket Channel

Bitmex offers a variety of channels where you can subscribe to get real-time updates of market data, orders... Find below a sample of how subscribe to a Trade Channel:

Delphi (VCL / FireMonkey)
oClient := TsgcWebSocketClient.Create(nil);
oBitmex := TsgcWSAPI_Bitmex.Create(nil);
oBitmex.Client := oClient;
oBitmex.Subscribe(btmTrade, 'XBTUSD');
procedure OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string);
begin
// here you will receive the trade updates
end;
C++ Builder
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex();
oBitmex->Client = oClient;
oBitmex->Subscribe(btmTrade, "XBTUSD");
void OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string)
{
// here you will receive the trade updates
}
.NET (C#)
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex();
oBitmex.Client = oClient;
oBitmex.Subscribe(btmTrade, "xbtusd");	
void OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string)
{
// here you will receive the tradeupdates
}

Sources used to build this document

Every external claim links back to a primary source. The online-help references decode the canonical deep-link the company maintains for this component.

Document scope. This document covers the publicly-documented surface of the Bitstamp API component shipped with sgcWebSockets. For full property, method and event reference consult the online help linked above.