livecoin

package module
v0.0.0-...-0e5e6a8 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2017 License: MIT Imports: 14 Imported by: 0

README

go-livecoin

go-livecoin is an implementation of the livecoin API (public and private) in Golang.

This version implement V1.1 livecoin API and the new HMAC authentification.

Import

import "github.com/bitbandi/go-livecoin"

Usage

In order to use the client with go's default http client settings you can do:

package main

import (
	"fmt"
	"github.com/bitbandi/go-livecoin"
)

const (
	API_KEY    = "YOUR_API_KEY"
	API_SECRET = "YOUR_API_SECRET"
)

func main() {
	// livecoin client
	livecoin := livecoin.New(API_KEY, API_SECRET)

	// Get balances
	balances, err := livecoin.GetBalances()
	fmt.Println(err, balances)
}

In order to use custom settings for the http client do:

package main

import (
	"fmt"
	"net/http"
	"time"
	"github.com/bitbandi/go-livecoin"
)

const (
	API_KEY    = "YOUR_API_KEY"
	API_SECRET = "YOUR_API_SECRET"
)

func main() {
	httpClient := &http.Client{
		Timeout: time.Second * 10,
	}

	// livecoin client
	bc := livecoin.NewWithCustomHttpClient(conf.livecoin.ApiKey, conf.livecoin.ApiSecret, httpClient)

	// Get balances
	balances, err := livecoin.GetBalances()
	fmt.Println(err, balances)
}

See "Examples" folder for more... examples

Documentation

Overview

Package Livecoin is an implementation of the Livecoin API in Golang.

Index

Constants

View Source
const (
	API_BASE = "https://api.livecoin.net" // Livecoin API endpoint
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(apiKey, apiSecret string) (c *client)

NewClient return a new Livecoin HTTP client

func NewClientWithCustomHttpConfig

func NewClientWithCustomHttpConfig(apiKey, apiSecret string, httpClient *http.Client) (c *client)

NewClientWithCustomHttpConfig returns a new Livecoin HTTP client using the predefined http client

func NewClientWithCustomTimeout

func NewClientWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) (c *client)

NewClient returns a new Livecoin HTTP client with custom timeout

Types

type Balance

type Balance struct {
	Type     string  `json:"type"`
	Currency string  `json:"currency"`
	Value    float64 `json:"value"`
}

type Livecoin

type Livecoin struct {
	// contains filtered or unexported fields
}

livecoin represent a livecoin client

func New

func New(apiKey, apiSecret string) *Livecoin

New returns an instantiated livecoin struct

func NewWithCustomHttpClient

func NewWithCustomHttpClient(apiKey, apiSecret string, httpClient *http.Client) *Livecoin

NewWithCustomHttpClient returns an instantiated livecoin struct with custom http client

func NewWithCustomTimeout

func NewWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) *Livecoin

NewWithCustomTimeout returns an instantiated livecoin struct with custom timeout

func (*Livecoin) GetBalance

func (b *Livecoin) GetBalance(currency string) (balance Balance, err error)

Getbalance is used to retrieve the balance from your account for a specific currency. currency: a string literal for the currency (ex: LTC)

func (*Livecoin) GetBalances

func (b *Livecoin) GetBalances() (balances []Balance, err error)

GetBalances is used to retrieve all balances from your account

func (*Livecoin) GetTrades

func (b *Livecoin) GetTrades(currencyPair string) (trades []Trade, err error)

GetTrades used to retrieve your trade history. market string literal for the market (ie. BTC/LTC). If set to "all", will return for all market

func (*Livecoin) GetTransactions

func (b *Livecoin) GetTransactions(start uint64, end uint64) (transactions []Transaction, err error)

GetTransactions is used to retrieve your withdrawal and deposit history "Start" and "end" are given in UNIX timestamp format in miliseconds and used to specify the date range for the data returned.

func (*Livecoin) SetDebug

func (c *Livecoin) SetDebug(enable bool)

set enable/disable http request/response dump

type Trade

type Trade struct {
	Id            uint64    `json:"id"`
	ClientOrderId uint64    `json:"clientorderid"`
	Type          string    `json:"type"`
	Symbol        string    `json:"symbol"`
	Date          time.Time `json:"datetime"`
	Price         float64   `json:"price"`
	Quantity      float64   `json:"quantity"`
	Commission    float64   `json:"commission"`
}

func (*Trade) UnmarshalJSON

func (t *Trade) UnmarshalJSON(data []byte) error

type Transaction

type Transaction struct {
	Id            string    `json:"id"`
	Type          string    `json:"type"`
	Date          time.Time `json:"date"`
	Amount        float64   `json:"amount"`
	Fee           float64   `json:"fee"`
	FixedCurrency string    `json:"fixedCurrency"`
	TaxCurrency   string    `json:"taxCurrency"`
	External      string    `json:"external"`
	ExternalKey   string    `json:"externalKey"`
	Login         string    `json:"login"`
}

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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