Initial Setup
- Create a Coinbase Exchange Account: Sign up at Coinbase Exchange.
- Generate an API Key: From the web UI, navigate to API.
- Authenticate: Ensure you authenticate all API requests. Detailed guidance is available at API Authentication.
REST API URL
https://api.exchange.coinbase.com
Using the Exchange Go SDK
Setting up the SDK
First, initialize a new Go module, install the Exchange Go SDK, and tidy dependencies. Run the following commands in your project directory, replacing example.com/test with your desired project path:Credentials
struct and create a new client. The Credentials struct is JSON enabled. Ensure that Exchange API credentials are stored in a secure manner.
EXCHANGE_CREDENTIALS
environment variable to your ~/.zshrc
file:
Making your first API call
After initializing the client, you need to set up the appropriate service to access specific API endpoints. Specific examples are provided below.Listing Accounts
Account IDs are needed in order to track asset-level events, e.g. transfers and ledger. To list all accounts, initialize the accounts service, pass in the request object, check for an error, and, if nil, process the response.Get Account Transfers
You can use account IDs to track historical transfers. To get a specific account’s transfer history, initialize the accounts service if you haven’t already, pass in the request object with account ID, check for an error, and, if nil, process the response.Listing Profiles
Certain requests require that you know your Profile ID. To list all profile IDs associated with your Exchange account, initialize the profiles service, pass in the request object, check for an error, and, if nil, process the response.Get Product Details
To get product details, initialize the products service, pass in the request object with the Product ID (e.g.BTC-USD
) you want data for, check for an error, and if nil, process the response.