CoinbaseSdk.Core
0.1.0
dotnet add package CoinbaseSdk.Core --version 0.1.0
NuGet\Install-Package CoinbaseSdk.Core -Version 0.1.0
<PackageReference Include="CoinbaseSdk.Core" Version="0.1.0" />
<PackageVersion Include="CoinbaseSdk.Core" Version="0.1.0" />
<PackageReference Include="CoinbaseSdk.Core" />
paket add CoinbaseSdk.Core --version 0.1.0
#r "nuget: CoinbaseSdk.Core, 0.1.0"
#:package CoinbaseSdk.Core@0.1.0
#addin nuget:?package=CoinbaseSdk.Core&version=0.1.0
#tool nuget:?package=CoinbaseSdk.Core&version=0.1.0
Coinbase .NET Core Library
Overview
The Coinbase .NET Core Library (CoinbaseSdk.Core) is the foundational building block for Coinbase .NET SDKs. It provides a standardized, robust, and thread-safe infrastructure for building API clients, handling authentication, HTTP communication, and serialization.
This library is primarily intended for internal use by Coinbase SDKs but is also available for advanced users building custom integrations requiring a standardized base.
Key Features
- Base Client Architecture: Abstract
CoinbaseClientmanaging request lifecycles with extensible hooks (BuildRequest,ConfigureRequest,ValidateResponse). - Resilient HTTP Communication: Wrapper around
System.Net.Http.HttpClientwith built-in Polly retry policies for transient failure handling. - Robust Serialization:
JsonUtilitywrapper aroundSystem.Text.Jsonfeaturing:NullOnUnknownEnumConverter: Graceful handling of new/unknown enum members.UtcIso8601DateTimeOffsetConverter: Standardized ISO-8601 date/time processing.- Thread-safe initialization using
Lazy<T>.
- Centralized Configuration:
HttpClientDefaultsandRetryPolicyDefaultsensuring consistent default behavior across SDKs. - Standardized Error Handling: Hierarchy of exceptions (
CoinbaseException,CoinbaseClientException) for uniform error reporting.
HTTP Client & Retries
The library uses SystemNetHttpClient to execute requests. By default, it performs a single attempt. You can enable retries using CallOptions, which leverages Polly's decorrelated jitter backoff strategy to handle transient failures (like rate limits or 5xx errors) without causing retry storms.
Retries can be configured at two levels:
- Per-Client: Set default behavior for all requests made by a client instance.
- Per-Request: Override behavior for a specific API call.
Configuration Examples
Per-Request Configuration:
var callOptions = new CallOptions
{
MaxRetries = 2,
ShouldRetryOnStatusCodes = true,
RetryableStatusCodes = new HashSet<HttpStatusCode> { HttpStatusCode.TooManyRequests }
};
// options are passed to the SendRequestAsync method
var response = await client.SendRequestAsync<MyResponse>(..., callOptions);
Per-Client Configuration:
var httpClient = new SystemNetHttpClient(
defaultCallOptions: new CallOptions
{
MaxRetries = 3,
ShouldRetryOnStatusCodes = true,
RetryableStatusCodes = new HashSet<HttpStatusCode> { HttpStatusCode.TooManyRequests }
});
var client = new MyCoinbaseClient(credentials, httpClient: httpClient);
Retry Configuration Options
| Option | Default | Description |
|---|---|---|
MaxRetries |
0 |
Maximum number of retry attempts (0 disables retries). |
MedianFirstRetryDelay |
500ms | Target median delay for the first retry (subject to jitter). |
MaxRetryDelay |
1s | Maximum delay cap for any retry attempt. |
ShouldRetryOnStatusCodes |
false |
Whether to retry on specific HTTP status codes. |
RetryableStatusCodes |
empty | Set of status codes to retry (e.g., 429, 503). |
Note: Retry attempts honor the
CancellationTokenprovided to the request. If canceled, pending retries are aborted.
Installation
dotnet add package CoinbaseSdk.Core
License
This project is licensed under the Apache License, Version 2.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Polly (>= 7.2.4)
- Polly.Contrib.WaitAndRetry (>= 1.1.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CoinbaseSdk.Core:
| Package | Downloads |
|---|---|
|
CoinbaseSdk.Prime
Coinbase Prime .NET SDK |
|
|
CoinbaseSdk.Intx
Coinbase INTX .NET SDK |
GitHub repositories
This package is not used by any popular GitHub repositories.