Deprecated: This repository has moved to github.com/coinbase/prime-sdk-dotnet. Install with
dotnet add package CoinbaseSdk.Prime. The package ID is unchanged; NuGet releases 0.7.0+ are published from the canonical repository. This repository is no longer maintained.
The Coinbase Prime .NET SDK is a sample library that demonstrates the structure of a Coinbase Prime driver for the REST APIs.
- .NET 10 SDK or later
- Coinbase Prime API credentials (access key, passphrase, and signing key), which can be created in the Prime web console under Settings > APIs
dotnet add package CoinbaseSdk.Prime --version x.y.zCoinbase Prime API credentials can be provided via environment variables. Copy the example file and populate your credentials:
cp .env.example .envRequired environment variables:
PRIME_ACCESS_KEY=your-access-key
PRIME_PASSPHRASE=your-passphrase
PRIME_SIGNING_KEY=your-signing-keyOptional environment variables used by examples:
PRIME_ENTITY_ID=your-entity-id
PRIME_PORTFOLIO_ID=your-portfolio-idEntity ID can be retrieved by calling Get Portfolio.
Initialize the client using environment variables (automatically loads a .env file if present):
var client = CoinbasePrimeClient.FromEnv();Or construct credentials manually:
var credentials = new CoinbaseCredentials(accessKey, passphrase, signingKey);
var client = new CoinbasePrimeClient(credentials);Once the client is initialized, instantiate a service to make the desired call. For example, to list portfolios:
var portfoliosService = new PortfoliosService(client);
var response = portfoliosService.ListPortfolios(new ListPortfoliosRequest());Or to list activities for a portfolio using the request builder:
var activitiesService = new ActivitiesService(client);
var request = new ListActivitiesRequest.ListActivitiesRequestBuilder()
.WithPortfolioId(portfolioId)
.Build();
var response = activitiesService.ListActivities(request);The Prime public OpenAPI specification is vendored at apiSpec/prime-public-api-spec.yaml. To refresh it:
make fetch-specTo build the sample library, ensure that .NET 10 SDK or later is installed and then run:
dotnet build prime-sdk-dotnet.slnEach example under src/CoinbaseSdk/PrimeExample/examples/ is a standalone .cs file executable directly with .NET 10+:
dotnet run --file src/CoinbaseSdk/PrimeExample/examples/portfolios/ListPortfolios.cs
dotnet run --file src/CoinbaseSdk/PrimeExample/examples/portfolios/GetPortfolio.cs -- --portfolioId <portfolio-id>
dotnet run --file src/CoinbaseSdk/PrimeExample/examples/activities/ListActivities.cs -- --portfolioId <portfolio-id>
dotnet run --file src/CoinbaseSdk/PrimeExample/examples/balances/ListEntityBalances.cs -- --entityId <entity-id>On Unix systems with executable permissions set, examples can also be invoked directly:
./src/CoinbaseSdk/PrimeExample/examples/portfolios/ListPortfolios.csAvailable example categories: activities, addressbook, advancedtransfer, allocations, assets, balances, commission, financing, futures, invoice, onchainaddressbook, orders, paymentmethods, portfolios, positions, products, staking, transactions, users, wallets.
If you discover a security vulnerability within this SDK, please see our Security Policy for disclosure information.
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.