Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/coinbase-api/llms.txt
Use this file to discover all available pages before exploring further.
coinbase-api supports two distinct authentication schemes. Which scheme you need depends entirely on which Coinbase product you are connecting to. This page explains both methods, shows exact configuration examples for every client, and documents every field in RestClientOptions.
Method 1: JWT Authentication (ECDSA / ED25519)
Used by:CBAdvancedTradeClient, CBAppClient, and WebsocketClient (when connecting to Advanced Trade or App feeds).
Coinbase’s Advanced Trade and App APIs use short-lived JSON Web Tokens (JWTs). You sign each request with a CDP API private key, and the SDK generates and attaches the JWT automatically. You never need to construct a JWT yourself.
Coinbase issues two key formats — both are supported and detected automatically at runtime:
| Format | apiKey value | apiSecret value |
|---|---|---|
| ECDSA | Full key name path (e.g. organizations/.../apiKeys/...) | PEM-formatted EC private key string including -----BEGIN EC PRIVATE KEY----- header/footer |
| ED25519 | Short key ID | Base64-encoded private key string |
Getting your CDP API key
- Go to https://www.coinbase.com/settings/api.
- Click New API Key and select the scopes your application needs.
- Download the generated
cdp_api_key.jsonfile — it containsnameandprivateKeyfields.
ECDSA key configuration
ED25519 key configuration
Using the downloaded cdp_api_key.json directly
You can parse and pass the downloaded JSON file as the cdpApiKey option instead of splitting it into apiKey and apiSecret. The SDK extracts both fields internally.
CBAppClient — same credentials, different client
Method 2: API Key + Secret + Passphrase
Used by:CBExchangeClient, CBInternationalClient, CBPrimeClient.
These platforms use HMAC-based request signing. Each request is signed with the API secret and must also include a passphrase that was chosen at key creation time. This passphrase is not your account password.
CBExchangeClient
CBInternationalClient
CBPrimeClient
Sandbox Environments
Coinbase provides sandbox environments for two of the six platforms:| Client | Sandbox available | useSandbox: true base URL |
|---|---|---|
CBExchangeClient | ✅ Yes | https://api-public.sandbox.exchange.coinbase.com |
CBInternationalClient | ✅ Yes | https://api-n5e1.coinbase.com |
CBAdvancedTradeClient | ❌ No | — |
CBAppClient | ❌ No | — |
CBPrimeClient | ❌ No | — |
CBCommerceClient | ❌ No | — |
useSandbox: true in your RestClientOptions to route requests to the sandbox:
RestClientOptions Reference
Every REST client constructor accepts aRestClientOptions object. All fields are optional unless your chosen API requires specific credentials.
Your API key identifier.
- Advanced Trade / App APIs: The full CDP key name, e.g.
organizations/{org_id}/apiKeys/{key_id}. - Exchange / International / Prime APIs: The API key string issued by Coinbase.
Your API secret.
- Advanced Trade / App APIs: The private key string. For ECDSA keys this is the full PEM block including
-----BEGIN EC PRIVATE KEY-----header and footer with embedded\ncharacters. For ED25519 keys this is the base64 string. - Exchange / International / Prime APIs: The HMAC secret used to sign requests.
Your API passphrase. Required only for
CBExchangeClient, CBInternationalClient, and CBPrimeClient. This is the passphrase you chose when creating the key — not your Coinbase account password.An alternative to
apiKey + apiSecret for JWT-based clients. Pass the parsed contents of your downloaded cdp_api_key.json file as { name: string; privateKey: string }. The SDK maps name → apiKey and privateKey → apiSecret automatically.Route requests to the Coinbase sandbox environment. Only has an effect for
CBExchangeClient and CBInternationalClient. For all other clients the sandbox URL is not available and this option is ignored.Lifetime in seconds of each generated JWT for Advanced Trade and App API requests. Increase this if you encounter token expiry errors on slow networks; decrease it if you want shorter credential windows.
Override the base URL used for all REST requests, e.g.
https://api.differentUrl.com. Useful for proxies, local mock servers, or testing against a custom endpoint.When
true, the SDK throws an error if any request parameter is undefined. Useful during development to catch missing required fields early.Enable HTTP keep-alive on the underlying
axios agent, reusing TCP connections across multiple requests for improved throughput in high-frequency scenarios.When
keepAlive is true, controls the interval (in milliseconds) between TCP keep-alive packets. Defaults to 1000 ms as provided by the Node.js http.Agent.When
true, the SDK post-processes HTTP error responses into structured JavaScript errors with status code and body information attached. Set to false to receive raw axios errors.Sets the
Accept-Language header for localized error messages from the Coinbase App API. Supported values: de, en, es, es-mx, fr, id, it, nl, pt, pt-br. Note: only applies to CBAppClient.Environment Variables Pattern
Always load credentials from the environment rather than embedding them in code:Related
- Quickstart — make your first API call.
- Introduction — overview of all six REST clients and features.
- Coinbase API Key Management — create and manage your API keys.