Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
Alessandro Sanino edited this page Aug 23, 2017 · 9 revisions

This wrapper will allow to connect to Bittrex API (version 2.0)

Getting the package

$ go get github.com/thebotguys/golang-bittrex-api

Calling the API functions

For Public API is simple:

result, err := bittrex.APIFuncDesired(parameters)
if err != nil {
    // Handle error
}
// For example
marketSummaries, err := bittrex.GetMarketSummary("BTC-ETH")
if err != nil {
    fmt.Println("ERROR OCCURRED: ", err)
}

For Private API is almost equally simple, you have to provide an auth struct with your keys:

auth := bittrex.Auth{
    PublicKey: "YOUR-PUBLIC-KEY",
    SecretKey: "YOUR-SECRET-KEY",
}
result, err := bittrex.PrivateAPIFuncDesired(auth, parameters)
if err != nil {
    // Handle error
}
// For example
balances, err := bittrex.GetBalance(auth, "BTC")
if err != nil {
    fmt.Println("ERROR OCCURRED: ", err)
}

If you are VERY HARDCORE you can use an Options struct to handle all connections parameters, like Connection Timeout:

// Currently this feature is not implemented
marketSummaries, err := bittrex.GetMarketSummaries(&bittrex.Options{
    ConnTimeout: time.Second * 30,
})
if err != nil {
    fmt.Println("ERROR OCCURRED: ", err)
}

Check out the tests for an example of usage, but almost everytime will be as simple as the code above.

You are strongly advised to check if the API is online at the start of your program, just copy paste the following code:

err := bittrex.IsAPIAlive()
if err != nil {
    fmt.Println("CANNOT REACH BITTREX API SERVERS: ", err)
}

Roadmap

  1. Public API

    These API are public and do not require API keys to work.

  2. Private API (WORK IN PROGRESS)