An alternative Golang package to interact with the Coinbase v2 API.
Note that this project is still work in progress!
Install:
go get github.com/mikejoh/coinbase-go
Import (with alias):
import cb "github.com/mikejoh/coinbase-go"
Instantiate client with config (using import alias):
package main
import cb "github.com/mikejoh/coinbase-go"
func main() {
config := cb.NewConfig(
cb.ApiKey("key"),
cb.Secret("secret"),
)
client := cb.NewClient(config)
}
rates, err := client.ExchangeRates(context.Background(), "BTC")
if err != nil {
log.Fatal(err)
}
fmt.Println(rates)
currencies, err := client.Currencies(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(currencies)
prices, err := client.Prices(context.Background(), "BTC-SEK", "sell")
if err != nil {
log.Fatal(err)
}
fmt.Println(prices)
time, err := client.Time(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(time)
- Build:
make client
The binary is created in ./bin
.
- 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
- Add code documentation
- Rate limit
- Pagination
- Header signing (auth)
- Implement Wallet endpoints
- Implement a more generic way of making client API calls, DRY.