> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cdp.coinbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart - Getting Started with Prime

This quickstart walks through creating an API key, setting up the Prime Go SDK, and making your first few API calls.

## Initial Setup

1. **Create a Coinbase Prime Account:** Sign up at [Coinbase Prime](https://prime.coinbase.com/).
2. **Generate an API Key:** From the web UI, navigate to Settings -> APIs.
3. **Authenticate:** Ensure you authenticate all API requests. Detailed guidance is available at [API Authentication](https://docs.cdp.coinbase.com/prime/rest-api/authentication.md).

> [!NOTE]
>
> **REST API URL:**
>
> `https://api.prime.coinbase.com/v1`

## Using the Prime SDKs

> [tab] Java
>
> ### Installation
>
> The [Coinbase Prime Java SDK](https://github.com/coinbase/prime-sdk-java) supports Java versions 11+.
>
> Check your Java version:
>
> ```bash lines wrap theme={null}
> java --version
> ```
>
> #### Install the Maven Dependency
>
> ```xml lines wrap theme={null}
> <dependency>
>     <groupId>com.coinbase.prime</groupId>
>     <artifactId>coinbase-prime-sdk-java</artifactId>
>    <version>1.0.0</version>
> </dependency>
> ```
>
> ### Making your first API call
>
> #### Initialize Prime Client
>
> The following code snippet demonstrates how to initialize the Prime client.
>
> ```java lines wrap theme={null}
> package com.coinbase.examples;
>
> import com.coinbase.prime.client.CoinbasePrimeClient;
> import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
>
> import com.fasterxml.jackson.databind.ObjectMapper;
>
> public class Main {
>     public static void main(String[] args) {
>         String credsStringBlob = System.getenv("COINBASE_PRIME_CREDENTIALS");
>         ObjectMapper mapper = new ObjectMapper();
>
>         CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(credsStringBlob);
>         CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
>     }
> }
> ```
>
> #### Listing Portfolios
>
> Update the code snippet with the service invocation and call to make your first API call with Prime to List Portfolios.
>
> ```java [expandable] lines wrap theme={null}
> package com.coinbase.examples;
>
> import com.coinbase.prime.client.CoinbasePrimeClient;
> import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
> import com.coinbase.prime.factory.PrimeServiceFactory;
> import com.coinbase.prime.model.portfolios.ListPortfoliosResponse;
> import com.coinbase.prime.portfolios.PortfoliosService;
>
> import com.fasterxml.jackson.databind.ObjectMapper;
>
> public class Main {
>     public static void main(String[] args) {
>         String credsStringBlob = System.getenv("COINBASE_PRIME_CREDENTIALS");
>         ObjectMapper mapper = new ObjectMapper();
>
>         CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(credsStringBlob);
>         CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
>
>         PortfoliosService portfoliosService = PrimeServiceFactory.createPortfoliosService(client);
>         ListPortfoliosResponse listPortfoliosResponse = portfoliosService.listPortfolios();
>
>         System.out.println(mapper.writeValueAsString(listPortfoliosResponse));
>     }
> }
> ```

> [tab] .NET
>
> ### Installation
>
> The [Coinbase Prime .NET SDK](https://github.com/coinbase/prime-sdk-dotnet) supports .NET version 8.0+.
>
> Check your .NET version:
>
> ```bash lines wrap theme={null}
> dotnet --version
> ```
>
> The SDK is vended through [NuGet](https://www.nuget.org/packages/CoinbaseSdk.Prime) and available for installation via the `dotnet` CLI.
>
> ```bash lines wrap theme={null}
> dotnet add package CoinbaseSdk.Prime --version x.y.z
> ```
>
> or if using [paket](https://fsprojects.github.io/Paket/):
>
> ```bash lines wrap theme={null}
> paket add CoinbaseSdk.Prime --version x.y.z
> ```
>
> ### Making your first API call
>
> #### Initialize Prime Client
>
> The following code snippet demonstrates how to initialize the Prime client:
>
> ```csharp [expandable] lines wrap theme={null}
> namespace CoinbaseSdk.PrimeExample.Example
> {
>   using CoinbaseSdk.Core.Credentials;
>   using CoinbaseSdk.Core.Serialization;
>   using CoinbaseSdk.Prime.Client;
>
>   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;
>       }
>
>       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!);
>     }
>   }
> }
> ```
>
> #### Listing Portfolios
>
> Update the code snippet with the service invocation and call to make your first API call with Prime to List Portfolios.
>
> ```csharp [expandable] lines wrap theme={null}
> 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 listPortfoliosResponse = portfoliosService.ListPortfolios();
>
>       Console.WriteLine($"Portfolio: {serializer.Serialize(portfolio)}");
>     }
>   }
> }
> ```

> [tab] Go
>
> ### Installation
>
> The [Coinbase Prime Go SDK](https://github.com/coinbase/prime-sdk-go) works with [Go](https://go.dev/) 1.19+
>
> Check your Golang version:
>
> ```bash lines wrap theme={null}
> go version
> ```
>
> Initialize a new Go module and tidy dependencies. Run the following commands in your project directory, replacing `example.com/test` with a proper project directory:
>
> ```bash lines wrap theme={null}
> go mod init example.com/test
> go mod tidy
> go build
> ```
>
> Install the Golang SDK:
>
> ```bash lines wrap theme={null}
> go get github.com/coinbase/prime-sdk-go
> ```
>
> To use the Prime Go SDK, initialize the `Credentials` struct and create a new client. The `Credentials` struct is JSON enabled. Ensure that Prime API credentials are stored in a secure manner.
>
> There are convenience functions to read the credentials as an environment variable (`credentials.ReadEnvCredentials`) and to deserialize the JSON structure (`credentials.UnmarshalCredentials`) if pulled from a different source. The JSON format expected for running this SDK is:
>
> ```bash lines wrap theme={null}
> export PRIME_CREDENTIALS='{ "accessKey": "", "passphrase": "", "signingKey": "", "portfolioId": "", "svcAccountId": "" }'
> ```
>
> These should be stored in `~/.zshrc` or `~/.bashrc`. You may proceed initially without knowing your Portfolio ID or Entity ID. The SDK will return these values in the response when you make your first API call below.
>
> ### Making your first API call
>
> #### Initialize Prime Client
>
> The following code snippet demonstrates how to initialize the Prime client.
>
> ```go lines wrap theme={null}
> package main
>
> import (
>     "log"
>
>     "github.com/coinbase/prime-sdk-go/client"
>     "github.com/coinbase/prime-sdk-go/credentials"
> )
>
> func main() {
>     primeCredentials, err := credentials.ReadEnvCredentials("PRIME_CREDENTIALS")
>     if err != nil {
>         log.Fatalf("unable to load prime credentials: %v", err)
>     }
>
>     httpClient, err := client.DefaultHttpClient()
>     if err != nil {
>         log.Fatalf("unable to load default http client: %v", err)
>     }
>
>     primeClient := client.NewRestClient(primeCredentials, httpClient)
> }
> ```
>
> #### Listing Portfolios
>
> Update the code snippet with the service invocation and call to make your first API call with Prime to List Portfolios.
>
> ```go [expandable] lines wrap theme={null}
> package main
>
> import (
>     "context"
>     "encoding/json"
>     "log"
>
>     "github.com/coinbase/prime-sdk-go/client"
>     "github.com/coinbase/prime-sdk-go/credentials"
>     "github.com/coinbase/prime-sdk-go/portfolios"
> )
>
> func main() {
>     primeCredentials, err := credentials.ReadEnvCredentials("PRIME_CREDENTIALS")
>     if err != nil {
>         log.Fatalf("unable to load prime credentials: %v", err)
>     }
>
>     httpClient, err := client.DefaultHttpClient()
>     if err != nil {
>         log.Fatalf("unable to load default http client: %v", err)
>     }
>
>     primeClient := client.NewRestClient(primeCredentials, httpClient)
>
>     portfoliosService := portfolios.NewPortfoliosService(primeClient)
>     response, err := portfoliosService.ListPortfolios(context.Background(), &portfolios.ListPortfoliosRequest{})
>     if err != nil {
>         log.Fatalf("Could not make request: %v", err)
>     }
>
>     jsonResponse, err := json.MarshalIndent(response, "", "  ")
>     if err != nil {
>         log.Fatalf("Could not marshall response to JSON: %v", err)
>     }
>     log.Println(string(jsonResponse))
> }
> ```

> [tab] Python
>
> ### Installation
>
> The [Coinbase Prime Python SDK](https://github.com/coinbase/prime-sdk-py) supports Python versions 3.9+.
>
> Check your Python version:
>
> ```bash lines wrap theme={null}
> python --version
> ```
>
> **Install the Python Dependency**
>
> ```bash lines wrap theme={null}
> pip install prime-sdk-py
> ```
>
> ### Making your first API call
>
> #### Initialize Prime Client
>
> The following code snippet demonstrates how to initialize the Prime client.
>
> ```python lines wrap theme={null}
> from credentials import Credentials
> from client import Client
>
> credentials = Credentials.from_env("PRIME_CREDENTIALS")
> client = Client(credentials)
> ```
>
> #### Listing Portfolios
>
> Update the code snippet with the service invocation and call to make your first API call with Prime to List Portfolios.
>
> ```python lines wrap theme={null}
> from list_portfolios import PrimeClient, ListPortfoliosRequest
>
> credentials = Credentials.from_env("PRIME_CREDENTIALS")
> prime_client = PrimeClient(credentials)
>
> request = ListPortfoliosRequest()
> try:
>     response = prime_client.list_portfolios(request)
>     print(response)
> except Exception as e:
>     print(f"failed to list portfolios: {e}")
> ```

> [tab] Rust
>
> ### Installation
>
> The [Coinbase Prime Rust SDK](https://github.com/coinbase/prime_sdk_rs) requires [Rust](https://www.rust-lang.org/tools/install) 1.61+.
>
> Check your Rust version:
>
> ```bash lines wrap theme={null}
> rustc --version
> ```
>
> Install the crate from [crates.io](https://crates.io/crates/prime_sdk_rs):
>
> ```bash lines wrap theme={null}
> cargo add prime_sdk_rs tokio
> ```
>
> Store your API credentials in an environment variable. The JSON format expected by the SDK is:
>
> ```bash lines wrap theme={null}
> export PRIME_CREDENTIALS='{"AccessKey": "", "SecretKey": "", "Passphrase": ""}'
> ```
>
> ### Making your first API call
>
> #### Initialize Prime Client
>
> The following code snippet demonstrates how to initialize the Prime client.
>
> ```rust lines wrap theme={null}
> use prime_sdk_rs::PrimeClient;
>
> #[tokio::main]
> async fn main() -> Result<(), Box<dyn std::error::Error>> {
>     let client = PrimeClient::new()?;
>     Ok(())
> }
> ```
>
> #### Listing Portfolios
>
> Update the code snippet with the service invocation and call to make your first API call with Prime to List Portfolios.
>
> ```rust [expandable] lines wrap theme={null}
> use prime_sdk_rs::{services::portfolios::PortfoliosService, PrimeClient};
>
> #[tokio::main]
> async fn main() -> Result<(), Box<dyn std::error::Error>> {
>     let client = PrimeClient::new()?;
>     let portfolios_service = PortfoliosService::new(client);
>     let response = portfolios_service.list_portfolios().await?;
>     println!("{:#?}", response);
>     Ok(())
> }
> ```
>
> ```base lines wrap theme={null}
> cargo run
> ```

> [tab] TypeScript
>
> ### Installation
>
> The [Coinbase Prime TypeScript SDK](https://github.com/coinbase/prime-sdk-ts) requires [Node.js](https://nodejs.org/) 18+.
>
> Check your Node.js version:
>
> ```bash lines wrap theme={null}
> node --version
> ```
>
> Install the npm package:
>
> ```bash lines wrap theme={null}
> npm install @coinbase/prime-sdk-ts
> ```
>
> Store your API credentials in an environment variable. The JSON format expected by the SDK is:
>
> ```bash lines wrap theme={null}
> export PRIME_CREDENTIALS='{"AccessKey": "", "SecretKey": "", "Passphrase": ""}'
> ```
>
> These should be stored in `~/.zshrc` or `~/.bashrc`. You may proceed initially without knowing your Portfolio ID or Entity ID. The SDK will return these values in the response when you make your first API call below.
>
> ### Making your first API call
>
> #### Initialize Prime Client
>
> The following code snippet demonstrates how to initialize the Prime client.
>
> ```typescript lines wrap theme={null}
> import { CoinbasePrimeClientWithServices } from '@coinbase/prime-sdk-ts';
>
> const client = CoinbasePrimeClientWithServices.fromEnv();
> ```
>
> #### Listing Portfolios
>
> Update the code snippet with the service invocation and call to make your first API call with Prime to List Portfolios.
>
> ```typescript [expandable] lines wrap theme={null}
> import { CoinbasePrimeClientWithServices } from '@coinbase/prime-sdk-ts';
>
> async function main() {
>   const client = CoinbasePrimeClientWithServices.fromEnv();
>   const response = await client.portfolios.listPortfolios();
>   console.log(response);
> }
>
> main().catch(console.error);
> ```
>
> ```bash lines wrap theme={null}
> npx tsx list-portfolios.ts
> ```

For technical support, see our [Help Center](https://help.coinbase.com/en/prime). If you do not have a Coinbase Prime account, or want to learn more, visit [coinbase.com/prime](https://www.coinbase.com/prime).
