A .NET client for the Coinbase Pro REST API.
dotnet add package LDZ.Coinbase.Api
Feed APIs provide market data and are public. By accessing the Coinbase Pro Market Data API, you agree to be bound by the Coinbase Market Data Terms of Use.
var factory = CoinbaseApiFactory.Create();
var marketData = factory.CreateMarketDataClient();
var trades = await marketData.GetTradesAsync("BTC-USD");
Trading APIs require authentication and provide access to placing orders and other account information. You must create an API key via the Coinbase Pro website.
var factory = CoinbaseApiFactory.Create(builder => builder.ConfigureApiKey(apiKey =>
{
apiKey.Key = "API_KEY";
apiKey.Secret = "API_SECRET";
apiKey.Passphrase = "API_PASS";
}));
var tradingClient = factory.CreateTradingClient();
var orders = await tradingClient.ListOrdersAsync();
static async Task Main(string[] args)
{
var factory = CoinbaseApiFactory.Create(builder => builder.ConfigureFeed(feedBuilder =>
{
feedBuilder.SubscribeToHeartbeatChannel(OnMessageReceived, "BTC-USD");
}));
var dataFeed = await factory.StartMarketDataFeed();
Console.ReadKey();
await dataFeed.StopAsync();
}
private static void OnMessageReceived(HeartbeatMessage message)
{
Console.WriteLine(message);
}
Integration tests target the public Coinbase sandbox. You'll need to create an API key and set the following environment variables:
$env:CoinbaseApiKey__Key = "API_KEY"
$env:CoinbaseApiKey__Secret = "API_SECRET"
$env:CoinbaseApiKey__Passphrase = "API_PASS"
cd test\LDZ.Coinbase.Test.Integration
dotnet test --logger:"console;verbosity=detailed"