CoinbaseSdk.Prime 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CoinbaseSdk.Prime --version 0.2.0
                    
NuGet\Install-Package CoinbaseSdk.Prime -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoinbaseSdk.Prime" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoinbaseSdk.Prime" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="CoinbaseSdk.Prime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoinbaseSdk.Prime --version 0.2.0
                    
#r "nuget: CoinbaseSdk.Prime, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CoinbaseSdk.Prime@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoinbaseSdk.Prime&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=CoinbaseSdk.Prime&version=0.2.0
                    
Install as a Cake Tool

Coinbase Prime .NET SDK

Overview

The Coinbase Prime .NET SDK is a sample library that demonstrates the structure of a Coinbase Prime driver for the REST APIs.

License

The Coinbase Prime .NET SDK sample library is free and open source and released under the Apache License, Version 2.0.

The application and code are only available for demonstration purposes.

Installation

The Coinbase Prime .NET SDK is vended through NuGet and available for installation via the dotnet CLI.

dotnet add package CoinbaseSdk.Prime --version x.y.z

or if using paket:

paket add CoinbaseSdk.Prime --version x.y.z

Usage

To use the Coinbase Prime .NET SDK, initialize the Credentials class and create a new client. The Credentials struct is JSON enabled. Ensure that Prime API credentials are stored in a secure manner.

namespace CoinbaseSdk.PrimeExample.Example
{
  using CoinbaseSdk.Core.Credentials;
  using CoinbaseSdk.Core.Serialization;
  using CoinbaseSdk.Prime.Client;
  using CoinbaseSdk.Prime.Model;
  using CoinbaseSdk.Prime.Orders;
  using CoinbaseSdk.Prime.Portfolios;

  class Example
  {
    static void Main()
    {
      string? credentialsBlob = Environment.GetEnvironmentVariable("COINBASE_PRIME_CREDENTIALS");
      if (credentialsBlob == null)
      {
        Console.WriteLine("COINBASE_PRIME_CREDENTIALS environment variable not set");
        return;
      }

      string? portfolioId = Environment.GetEnvironmentVariable("COINBASE_PRIME_PORTFOLIO_ID");
      if (portfolioId == null)
      {
        Console.WriteLine("COINBASE_PRIME_PORTFOLIO_ID environment variable not set");
        return;
      }

      var serializer = new JsonUtility();

      var credentials = serializer.Deserialize<CoinbaseCredentials>(credentialsBlob);

      if (credentials == null)
      {
        Console.WriteLine("Failed to parse COINBASE_PRIME_CREDENTIALS environment variable");
        return;
      }

      var client = new CoinbasePrimeClient(credentials!);

      var portfoliosService = new PortfoliosService(client);

      var portfolio = portfoliosService.GetPortfolioById(
        new GetPortfolioByIdRequest(portfolioId)).Portfolio!;

      Console.WriteLine($"Portfolio: {serializer.Serialize(portfolio)}");
    }
  }
}

The JSON format expected for COINBASE_PRIME_CREDENTIALS is:

{
  "accessKey": "",
  "passphrase": "",
  "signingKey": ""
}

For an example of how to use the client, see the Example file. To execute the example, run the following command:

dotnet run --project src/CoinbaseSdk.PrimeExample/CoinbaseSdk.PrimeExample.csproj

Warning: this does place a limit order for a very small amount of ADA. Please ensure that you have the necessary funds in your account before running this code. The example code should cancel the order, however if something breaks you may need to go manually cancel the order.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 147 5/29/2025
0.2.0 176 2/21/2025