Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.
/ coinbase Public archive

An unofficial go (golang) client for Coinbase API

License

Notifications You must be signed in to change notification settings

oxdapp/coinbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-Coinbase - Go Coinbase API unofficial Client

Getting started

Grab this dep

go get "github.com/BillotP/go-coinbase"

Write your api key and secrets in a .env file for example

COINBASE_APIKEY=myawesomeapikey
COINBASE_APISECRET=mysuperapisecret

And then in your code

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/BillotP/coinbase"
	"github.com/BillotP/coinbase/lib/models"
)

func main() {
	var (
		err        error
		pub        = os.Getenv("COINBASEPUB")
		priv       = os.Getenv("COINBASEPRIV")
		myaccounts *models.Accounts
		// Load client
		client = coinbase.New(&pub, &priv)
	)
	// Get all your accounts
	if myaccounts, err = client.GetAccounts(); err != nil {
		log.Fatal(err)
	}
	// List them
	for _, account := range myaccounts.Datas {
		fmt.Printf("%s: %s (%s %s)\n",
			account.Balance.Currency,
			account.Balance.Amount,
			account.NativeBalance.Amount,
			account.NativeBalance.Currency,
		)
	}
}

And finally run the whole thing

source .env
COINBASE_APIKEY=$COINBASE_APIKEY COINBASE_APISECRET=$COINBASEAPISECRET go run .

Et voila !

About

An unofficial go (golang) client for Coinbase API

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages