Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Public API

Alessandro Sanino edited this page Aug 28, 2017 · 7 revisions

Public API

This section describes how to use functions which implement Bittrex Public API

IsAPIAlive()

Checks if Bittrex servers are reachable by the client, returns an error if any encountered during the request.

func IsAPIAlive() error

// You can check as follows
err := bittrex.IsAPIAlive()
if err != nil {
    // Something has gone wrong, Servers are not reachable.
    return // or return err, it depends if you need the error.
}
// Servers are reachable

GetServerAPIVersion()

Returns the version of the API on the Bittrex servers.

func GetServerAPIVersion() (string, error)

// You can check as follows
version, err := bittrex.GetServerAPIVersion()
if err != nil {
    // Something has gone wrong, Servers are not reachable.
    return // or return err, it depends if you need the error.
}
fmt.Println("VERSION: ", version)

GetBTCPrice

Returns current BTC Price as shown from Bittrex API (which rely on a third-party service)

func GetBTCPrice() (*BTCPrice, error)

// Example
BTCPrice, err := bittrex.GetServerAPIVersion()
if err != nil {
    // Something has gone wrong, Servers are not reachable.
    return // or return err, it depends if you need the error.
}
fmt.Printf("BTC PRICE AT TIMESTAMP %s = %f.2 USD\n",
    BTCPrice.Timestamp, BTCPrice.USDValue)
BTCPrice implementation
type BTCPrice struct {
    USDValue float64
    Timestamp time.Time
}

GetMarketSummaries

Gets the full summaries from all markets.

func GetMarketSummaries() (MarketSummaries, error)

// Example
summaries, err := bittrex.GetMarketSummaries()
if err != nil {
    // Something has gone wrong, Servers are not reachable.
    return // or return err, it depends if you need the error.
}
for _, summary := range summaries {
    fmt.Println("SUMMARY: ", summary) // Print summary data, DON'T DO THIS
                                      // until a String() method is implemented
                                      // for this type from devs.for this type
                                      // from devs.
}
MarketSummary implementation
type MarketSummary struct {
	MarketName     string
	High           float64
	Low            float64
	Last           float64
	Bid            float64
	Ask            float64
	Volume         float64
	BaseVolume     float64
	Timestamp      string
	OpenBuyOrders  uint64
	OpenSellOrders uint64
	PrevDay        float64
	Created        string
}

type MarketSummaries []MarketSummary

GetMarketSummary

Gets the summary data from a specified market.

func GetMarketSummary() (*MarketSummary, error)

// Example
summary, err := bittrex.GetMarketSummary("BTC-ETH")
if err != nil {
    // Something has gone wrong, Servers are not reachable.
    return // or return err, it depends if you need the error.
}
fmt.Println("SUMMARY: ", summary) // Print summary data, DON'T DO THIS
                                  // until a String() method is implemented
                                  // for this type from devs.for this type
                                  // from devs.

GetMarkets

Returns the full data of all markets.

func GetMarkets() (Markets, error)

// Example
markets, err := bittrex.GetMarkets()
if err != nil {
    // Something has gone wrong, Servers are not reachable.
    return // or return err, it depends if you need the error.
}
for _, market := range markets {
    fmt.Println("SUMMARY: ", market) // Print market data, DON'T DO THIS
                                     // until a String() method is implemented
                                     // for this type from devs.
}
Market implementation
type Market struct {
	BaseCurrency       string
	BaseCurrencyLong   string
	MarketCurrency     string
	MarketCurrencyLong string
	MarketName         string
	MinTradeSize       float64
	IsActive           bool
	Created            string
	Notice             string
	IsSponsored        bool
	LogoURL            string
}

type Markets []Market

GetTicks()

Gets all candlesticks (ticks) to create a market’s candlestick chart.

func GetTicks() (Candlesticks, error)

// Example
candles, err := bittrex.GetTicks()
if err != nil {
    // Something has gone wrong, Servers are not reachable.
    return // or return err, it depends if you need the error.
}
for _, candle := range candles {
    fmt.Println("CANDLE: ", candle) // Print candle data, DON'T DO THIS
                                    // until a String() method is implemented
                                    // for this type from devs.
}
Candle implementation
type CandleStick struct {
	High       float64
	Open       float64
	Close      float64
	Low        float64
	Volume     float64
	BaseVolume float64
	Timestamp  candleTime
}

type CandleSticks []CandleStick

type candleTime time.Time

GetLatestTick()

Gets latest candlestick (tick) to create a market’s candlestick chart.

func GetLatestTick() (*Candlestick, error)

// Example
candle, err := bittrex.GetLatestTick()
if err != nil {
    // Something has gone wrong, Servers are not reachable.
    return // or return err, it depends if you need the error.
}
fmt.Println("CANDLE: ", candle) // Print candle data, DON'T DO THIS
                                // until a String() method is implemented
                                // for this type from devs.
Known issues :

If GetLatestTick is called with a oneMin interval every minute, it provides two minutes charts. Refer to THIS ISSUE for clarity.