sgcWebSockets · Technical Document

Kraken API

Kraken WebSocket v2 and REST client — public market-data plus authenticated account, order and balance streams.

Overview

WebSockets API offers real-time market data updates. WebSockets is a bidirectional protocol offering fastest real-time data, helping you build real-time applications. The public message types presented below do not require authentication. Private-data messages can be subscribed on a separate authenticated endpoint.

At a glance

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

Features

Technical specification

Standards & specsKraken WebSocket v2 API · Kraken REST API
Component classTsgcWSAPI_Kraken (unit sgcWebSocket_API_Kraken)
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.
OnKrakenSubscribedPublished or public property used to configure or query the component.
OnKrakenUnSubscribedPublished or public property used to configure or query the component.
OnConnectPublished or public property used to configure or query the component.
OnKrakenConnectPublished or public property used to configure or query the component.
OnKrakenSystemStatusPublished or public property used to configure or query the component.
OnKrakenSubscriptionErrorPublished or public property used to configure or query the component.
OnKrakenDataPublished or public property used to configure or query the component.
OnDisconnectPublished or public property used to configure or query the component.
OnKrakenHTTPExceptionPublished or public property used to configure or query the component.

Main methods

The principal public methods exposed by the component.

SubscribeTrade()Public procedure exposed by the component.
UnSubscribeTrade()Public procedure exposed by the component.
SubscribeOwnTrades()Public procedure exposed by the component.
UnSubscribeOwnTrades()Public procedure exposed by the component.
SubscribeOpenOrders()Public procedure exposed by the component.
UnSubscribeOpenOrders()Public procedure exposed by the component.
SubscribeTicker()Public procedure exposed by the component.
UnSubscribeTicker()Public procedure exposed by the component.
SubscribeOHLC()Public procedure exposed by the component.
UnSubscribeOHLC()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 API Kraken REST Private — Authentication configuration sourced from the online help.

About this scenario. REST Private API requires an API Key and API Secret, these values are provided by Kraken in your account.

Delphi (VCL / FireMonkey)

Kraken.ApiKey := 'api key';
Kraken.ApiSecret := 'api secret';

C++ Builder

Kraken->ApiKey = "api key";
Kraken->ApiSecret = "api secret";

.NET (C#)

Kraken.ApiKey = "api key";
Kraken.ApiSecret = "api secret";

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 · API Kraken WebSockets Private — Authentication

The API client must request an authentication "token" via the following REST API endpoint "GetWebSocketsToken" to connect to WebSockets Private endpoints. The token should be used within 15 minutes of creation. The token does not expire once a connection to a WebSockets API private message (openOrders or ownTrades) is maintained.

Delphi (VCL / FireMonkey)
Kraken.ApiKey := 'api key';
Kraken.ApiSecret := 'api secret';
C++ Builder
Kraken->ApiKey = "api key";
Kraken->ApiSecret = "api secret";
.NET (C#)
Kraken.ApiKey = "api key";
Kraken.ApiSecret = "api secret";

2 · API Kraken WebSockets Public — Methods

Client can ping server to determine whether connection is alive, server responds with pong.

Delphi (VCL / FireMonkey)
SubscribeTicker(['XBT/USD']);
C++ Builder
SubscribeTicker([L"XBT/USD"]);
.NET (C#)


  

3 · API Kraken REST Public — Methods

This method is to aid in approximating the skew time between the server and client. Returns Time in Unix format.

Delphi (VCL / FireMonkey)
Kraken.REST_API.GetAssetPairs(['XBTUSD']);
C++ Builder
Kraken->REST_API->GetAssetPairs(ARRAYOFCONST((L"XBTUSD")));
.NET (C#)
Kraken.REST_API.GetAssetPairs("XBTUSD");

4 · API Kraken WebSockets Private — Methods

Get a list of own trades, on first subscription, you get a list of latest 50 trades

Delphi (VCL / FireMonkey)
SubscribeOwnTrades();
C++ Builder
SubscribeOwnTrades();
.NET (C#)
SubscribeOwnTrades();

5 · API Kraken REST Private — Methods

Returns your account balance.

Delphi (VCL / FireMonkey)
Kraken.REST_API.GetAccountBalance();
C++ Builder
Kraken->REST_API->GetAccountBalance();
.NET (C#)
Kraken.REST_API.GetAccountBalance();

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 Kraken API component shipped with sgcWebSockets. For full property, method and event reference consult the online help linked above.