tar.Bitvavo.Api
1.0.1
dotnet add package tar.Bitvavo.Api --version 1.0.1
NuGet\Install-Package tar.Bitvavo.Api -Version 1.0.1
<PackageReference Include="tar.Bitvavo.Api" Version="1.0.1" />
paket add tar.Bitvavo.Api --version 1.0.1
#r "nuget: tar.Bitvavo.Api, 1.0.1"
// Install tar.Bitvavo.Api as a Cake Addin #addin nuget:?package=tar.Bitvavo.Api&version=1.0.1 // Install tar.Bitvavo.Api as a Cake Tool #tool nuget:?package=tar.Bitvavo.Api&version=1.0.1
tar.Bitvavo.Api
Full Bitvavo API with REST and WebSocket functionality.
- C# .NET Standard v2.0
- Nuget Package: https://www.nuget.org/packages/tar.Bitvavo.Api
Function
This library provides the functionalities of the Bitvavo API for REST and WebSocket (2.5.0).
Additionally it automatically
- authenticates via web socket, if needed
- converts JSON strings to mapped objects
- converts internally used Unix timestamps to the human readable date time format
- converts internally used number strings to real decimal numbers
- converts internally used enum strings to real enums
- provides additional and directly accessable useful informations in every response
Usage
BvRestClient bvRestClient = new(
accessWindow: TimeSpan.FromSeconds(10),
apiKey: yourApiKey,
apiSecret: yourApiSecret,
url: "https://api.bitvavo.com/v2"
);
BvWebSocketClient bvWebSocketClient = new(
accessWindow: TimeSpan.FromSeconds(10),
apiKey: yourApiKey,
apiSecret: yourApiSecret,
keepAliveInterval: TimeSpan.FromSeconds(5),
url: "wss://ws.bitvavo.com/v2/"
);
All parameters are optional:
accessWindow
: time window for each request that requires authentificationapiKey
&apiSecret
: are not required for public API endpoints but recommended for better rate limits/lock timeskeepAliveInterval
: the web sockets heartbeat between client and serverurl
: API base URL
REST Methods
You can use the main methods of the rest client and web socket client directly:
// for direct rest request usage you need to forward the expected response type <T>
var response1 = bvRestClient.SendRequest<T>(RestRequestOptions requestOptions);
var response2 = await bvRestClient.SendRequestAsync<T>(RestRequestOptions requestOptions);
But I recommend using the prepared methods which already have the correct parameters and response types:
// account actions
var cancelOrderResponse = await bvRestClient.AccountActions.CancelOrderAsync(...);
var cancelOrdersResponse = await bvRestClient.AccountActions.CancelOrdersAsync(...);
var placeLimitOrderResponse = await bvRestClient.AccountActions.PlaceLimitOrderAsync(...);
var placeMarketOrderResponse = await bvRestClient.AccountActions.PlaceMarketOrderAsync(...);
var placeStopLossLimitOrderResponse = await bvRestClient.AccountActions.PlaceStopLossLimitOrderAsync(...);
var placeStopLossOrderResponse = await bvRestClient.AccountActions.PlaceStopLossOrderAsync(...);
var placeTakeProfitLimitOrderResponse = await bvRestClient.AccountActions.PlaceTakeProfitLimitOrderAsync(...);
// etc.
// account infos
var balance = await bvRestClient.AccountInfos.GetBalanceAsync();
var deposits = await bvRestClient.AccountInfos.GetDepositHistoryAsync();
// etc.
// public infos
var asset = await bvRestClient.PublicInfos.GetAssetAsync(symbol);
var assets = await bvRestClient.PublicInfos.GetAssetsAsync();
var candles = await bvRestClient.PublicInfos.GetCandlesAsync(market, interval, limit, start, end);
var market = await bvRestClient.PublicInfos.GetMarketAsync(market);
var markets = await bvRestClient.PublicInfos.GetMarketsAsync();
// etc.
Account methods need authentication for which a valid API key & secret needs to be provided.
The returned Response<T>
class contains all necessary information:
Data
: the response message as mapped object of type <T>Error
: Bitvavo error descriptionErrorCode
: Bitvavo error codeIsSuccessful
: indicator if the request was successfulIsSuccessStatusCode
: if the http status code is a success statusJsonContent
: the response message as json stringRateLimit
: the current Bitvavo rate limitRateLimitRemaining
: your remaining rate limit pointsRateLimitResetAt
: the timestamp when the rate limit is reset atRequest
: the original requestResponseUri
: the uri you get the response fromServer
: server descriptionStatusCode
: the http status codeStatusDescription
: description of the http status codeVersion
: the http version
Web Socket Methods
You can use the main methods of the web socket client directly:
await bvWebSocketClient.AuthenticateAsync(long? requestId = null);
await bvWebSocketClient.ConnectAsync();
await bvWebSocketClient.CloseAsync();
await bvWebSocketClient.SendAsync(SendOptions sendOptions);
But I recommend using the prepared methods which already have the correct parameters and response types.
The same methods as for REST are provided and additionally you can use subscription methods:
// account actions
await bvWebSocketClient.AccountActions.CancelOrderAsync(...);
// etc.
// account infos
await bvWebSocketClient.AccountInfos.GetBalanceAsync();
// etc.
// public infos
var asset = await bvWebSocketClient.PublicInfos.GetAssetAsync(symbol);
// etc.
// subscriptions
await bvWebSocketClient.Subscriptions.SubscribeToAccountOrdersAsync()
await bvWebSocketClient.Subscriptions.SubscribeToAccountOrdersAsync(markets);
await bvWebSocketClient.Subscriptions.SubscribeToMarketCandlesAsync(markets, intervals);
await bvWebSocketClient.Subscriptions.SubscribeToMarketOrderBookAsync(markets);
await bvWebSocketClient.Subscriptions.SubscribeToMarketTicker24hAsync(markets);
await bvWebSocketClient.Subscriptions.SubscribeToMarketTickerAsync(markets);
await bvWebSocketClient.Subscriptions.SubscribeToMarketTradesAsync(markets);
await bvWebSocketClient.Subscriptions.UnsubscribeFromAccountOrdersAsync(markets);
await bvWebSocketClient.Subscriptions.UnsubscribeFromMarketCandlesAsync(markets, intervals);
await bvWebSocketClient.Subscriptions.UnsubscribeFromMarketOrderBookAsync(markets);
await bvWebSocketClient.Subscriptions.UnsubscribeFromMarketTicker24hAsync(markets);
await bvWebSocketClient.Subscriptions.UnsubscribeFromMarketTickerAsync(markets);
await bvWebSocketClient.Subscriptions.UnsubscribeFromMarketTradesAsync(markets);
Account methods need authentication for which a valid API key & secret needs to be provided. The authentication is done automatically beforehand, if necessary. Therefore it is checked if the last authentication is still valid, depending on the access window.
You are also able to set an additional requestId
parameter on each method which you will get back in the corresponding received message.
Web Socket Events
To receive web socket updates, you need to add event handlers for the corresponding web socket events and subscribe them.
For example:
// register/subscribe to events
bvWebSocketClient.OnClosing += BvWebSocketClient_OnClosing;
bvWebSocketClient.OnConnecting += BvWebSocketClient_OnConnecting;
bvWebSocketClient.OnMessageReceived += BvWebSocketClient_OnMessageReceived;
bvWebSocketClient.OnMessageSent += BvWebSocketClient_OnMessageSent;
bvWebSocketClient.OnStateChanged += BvWebSocketClient_OnStateChanged;
// your explicit event handler method where you handle on closing events
private void BvWebSocketClient_OnClosing(CallbackInfo info) {
MessageBox.Show(
info.Success
? "Connection closed"
: $"Connection not closed: {info.ErrorMessage}"
);
}
// your explicit event handler method where you handle on message received events
private void BvWebSocketClient_OnMessageReceived(CallbackInfo info) {
// ...
}
// etc.
The returned CallbackInfo
class contains all necessary information:
AccessWindow
: the accessable time for authenticated requestsClientAction
: action which triggered the callbackClientActionDescription
: action as textClosed
: last closed timestampDuration
: time the web socket is/was openErrorMessage
: description when an error occuredLastAuthed
: last authentication timestampOpened
: last opened timestampReceivedMessage
: received message infoAction
: the basic api method/endpoint usedAuthenticated
: authentication indicatorData
: the received message data as mapped objectsError
: Bitvavo error descriptionErrorCode
: Bitvavo error codeEvent
: base Bitvavo endpoint eventSubscriptionData
: the received subscription data as mapped objectsSubscriptions
: subscribed channelsRequestId
: the optionalrequestId
you have set
SentMessage
: sent message as JSON stringSentOptions
: options used to generate the send payloadSentPayload
: send message as mapped objectState
: the current state of the internal ClientWebSocketStateDescription
: state as textSuccess
: if the action was successfulTimestamp
: when the action occuredTriggeredByClient
: if the action was triggered by the client (you), otherwise by the serverUrl
: the URL the web socket is connected to
The provided information depends on the actual client action.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- RestSharp (>= 112.1.0)
- tar.WebSocket (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.