coinbase

package module
v0.0.0-...-0278b90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2014 License: MIT Imports: 8 Imported by: 0

README

Build Status

go-coinbase

A Coinbase API client in Go (golang). Focus is currently on buying and selling BTC, but eventually all methods will be supported.

Usage

  • First, get yourself a Coinbase api key: https://coinbase.com/account/api

  • Become familiar with the rate limits that apply to your account: https://coinbase.com/verifications

  • Install the library:

      go get github.com/grantmd/go-coinbase
    
  • Include it in your project:

      import "github.com/grantmd/go-coinbase"
    
  • Setup your Coinbase client:

      c := &coinbase.Client{
      APIKey: os.Getenv("COINBASE_API_KEY"),
    

    }

  • Make a call with your API key:

    balance, err := c.AccountBalance() if err != nil { log.Fatal(err) }

    fmt.Printf("%+v\n", balance)

Documentation

Index

Constants

View Source
const (
	COINBASE_API_ENDPOINT = "https://coinbase.com/api/v1/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountReceiveAddress

type AccountReceiveAddress struct {
	Success     bool
	Address     string
	CallbackUrl string `json:"callback_url"`
}

type Address

type Address struct {
	Address struct {
		Address     string
		CallbackUrl string `json:"callback_url"`
		Label       string
		CreatedAt   string `json:"created_at"`
	}
}

type Addresses

type Addresses struct {
	Addresses   []Address
	TotalCount  int `json:"total_count"`
	NumPages    int `json:"num_pages"`
	CurrentPage int `json:"current_page"`
}

type Amount

type Amount struct {
	Amount   float32 `json:",string"`
	Currency string
}

type Button

type Button struct {
	Type        string
	Name        string
	Description string
	ID          string
}

type Buys

type Buys struct {
	Success  bool
	Errors   []string
	Transfer Transfer
}

type CentsAmount

type CentsAmount struct {
	Cents       int
	CurrencyISO string `json:"currency_iso"`
}

type Client

type Client struct {
	APIKey string
	// contains filtered or unexported fields
}

The client holds the necessary keys and our HTTP client for making requests

func (*Client) GenerateAccountReceiveAddress

func (c *Client) GenerateAccountReceiveAddress(callbackURL string) (AccountReceiveAddress, error)

func (*Client) Get

func (c *Client) Get(api_method string, params url.Values) ([]byte, error)

func (*Client) GetAccountBalance

func (c *Client) GetAccountBalance() (Amount, error)

func (*Client) GetAccountReceiveAddress

func (c *Client) GetAccountReceiveAddress() (AccountReceiveAddress, error)

func (*Client) GetAddresses

func (c *Client) GetAddresses(page int, limit int, query string) (Addresses, error)

func (*Client) GetBuys

func (c *Client) GetBuys(quantity float32, agree_btc_amount_varies bool) (Buys, error)

func (*Client) GetContacts

func (c *Client) GetContacts() (Contacts, error)

func (*Client) GetCurrencies

func (c *Client) GetCurrencies() (Currencies, error)

func (*Client) GetExchangeRates

func (c *Client) GetExchangeRates() (ExchangeRates, error)

func (*Client) GetHistoricalPrices

func (c *Client) GetHistoricalPrices(page int) (string, error)

func (*Client) GetOrders

func (c *Client) GetOrders() (Orders, error)

func (*Client) GetPricesBuy

func (c *Client) GetPricesBuy() (PricesBuy, error)

func (*Client) GetPricesSell

func (c *Client) GetPricesSell() (PricesSell, error)

func (*Client) GetSells

func (c *Client) GetSells(quantity float32) (Sells, error)

func (*Client) GetSpotRate

func (c *Client) GetSpotRate() (Amount, error)

func (*Client) GetTransfers

func (c *Client) GetTransfers(page int, limit int) (Transfers, error)

func (*Client) GetUsers

func (c *Client) GetUsers() (Users, error)

func (*Client) PostForm

func (c *Client) PostForm(api_method string, params url.Values) ([]byte, error)

func (*Client) PostJSON

func (c *Client) PostJSON(api_method string, params map[string]interface{}) ([]byte, error)

type Contact

type Contact struct {
	Email string
}

type Contacts

type Contacts struct {
	Contacts    []Contact
	TotalCount  int
	NumPages    int
	CurrentPage int
}

type Currencies

type Currencies [][]string

type ExchangeRates

type ExchangeRates map[string]string

type Order

type Order struct {
	ID        string
	CreatedAt string
	Status    string

	TotalBTC    TotalCurrency
	TotalNative TotalCurrency

	Custom      string
	Button      Button
	Transaction Transaction
}

type Orders

type Orders struct {
	Orders      []Order
	TotalCount  int
	NumPages    int
	CurrentPage int
}

type PricesBuy

type PricesBuy struct {
	SubTotal Amount
	Fees     []map[string]Amount
	Total    Amount
}

type PricesSell

type PricesSell struct {
	SubTotal Amount
	Fees     []map[string]Amount
	Total    Amount
	Amount   string
	Currency string
}

type Sells

type Sells struct {
	Success  bool
	Errors   []string
	Transfer Transfer
}

type TotalCurrency

type TotalCurrency struct {
	Cents       int
	CurrencyISO string
}

type Transaction

type Transaction struct {
	ID            string
	Hash          string
	Confirmations int
}

type Transfer

type Transfer struct {
	ID            string
	Type          string
	Code          string
	CreatedAt     string `json:"created_at"`
	Fees          map[string]CentsAmount
	Status        string
	PayoutDate    string `json:"payout_date"`
	TransactionID string `json:"transaction_id"`
	BTC           Amount
	Subtotal      Amount
	Total         Amount
	Description   string
}

type Transfers

type Transfers struct {
	Transfers   []map[string]Transfer
	TotalCount  int `json:"total_count"`
	NumPages    int `json:"num_pages"`
	CurrentPage int `json:"current_page"`
}

type User

type User struct {
	User struct {
		ID             string
		Name           string
		Email          string
		TimeZone       string `json:"time_zone"`
		NativeCurrency string `json:"native_currency"`
		Balance        Amount
		BuyLevel       int    `json:"buy_level"`
		SellLevel      int    `json:"sell_level"`
		BuyLimit       Amount `json:"buy_limit"`
		SellLimit      Amount `json:"sell_limit"`
	}
}

type Users

type Users struct {
	Users []User
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL