https://github.com/mikejoh/coinbase-go
Coinbase API v2 client
https://github.com/mikejoh/coinbase-go
coinbase coinbase-api golang golang-package
Last synced: 11 months ago
JSON representation
Coinbase API v2 client
- Host: GitHub
- URL: https://github.com/mikejoh/coinbase-go
- Owner: mikejoh
- License: mit
- Created: 2021-01-18T08:23:17.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-12-06T19:44:18.000Z (over 4 years ago)
- Last Synced: 2025-07-06T09:51:54.533Z (12 months ago)
- Topics: coinbase, coinbase-api, golang, golang-package
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# coinbase-go

An alternative Golang package to interact with the [Coinbase](https://www.coinbase.com/) **v2 API**.
_Note that this project is still work in progress!_
## Installation
Install:
```
go get github.com/mikejoh/coinbase-go
```
Import (with alias):
```go
import cb "github.com/mikejoh/coinbase-go"
```
## Examples
Instantiate client with config (using import alias):
```go
package main
import cb "github.com/mikejoh/coinbase-go"
func main() {
config := cb.NewConfig(
cb.ApiKey("key"),
cb.Secret("secret"),
)
client := cb.NewClient(config)
}
```
### Exchange rates
```go
rates, err := client.ExchangeRates(context.Background(), "BTC")
if err != nil {
log.Fatal(err)
}
fmt.Println(rates)
```
### Currencies
```go
currencies, err := client.Currencies(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(currencies)
```
### Prices
```go
prices, err := client.Prices(context.Background(), "BTC-SEK", "sell")
if err != nil {
log.Fatal(err)
}
fmt.Println(prices)
```
### Time
```go
time, err := client.Time(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(time)
```
## Coinbase CLI
1. Build:
```
make client
```
The binary is created in `./bin`.
2. Example usage:
```
./bin/cb currencies
./bin/cb prices --pair BTC-SEK --type buy
./bin/cb exchange-rates
./bin/cb exchange-rates --currency SEK
./bin/cb time
```
## Resources
[v2 API ref](https://developers.coinbase.com/api/v2#introduction)
## Todo
* [ ] Add code documentation
* [ ] Rate limit
* [ ] Pagination
* [ ] Header signing (auth)
* [ ] Implement Wallet endpoints
* [ ] Implement a more generic way of making client API calls, DRY.