-
Notifications
You must be signed in to change notification settings - Fork 12
Home
This wrapper will allow to connect to Bittrex API (version 2.0)
For Public API is simple:
result, err := bittrex.APIFuncDesired(parameters)
if err != nil {
// Handle error
}
// For example
marketSummary, 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
balance, err := bittrex.GetBalance(auth, "BTC")
if err != nil {
fmt.Println("ERROR OCCURRED: ", err)
}
You are strongly advised to check if the API is online at the start of your program, with the following code:
err := bittrex.IsAPIAlive()
if err != nil {
fmt.Println("CANNOT REACH BITTREX API SERVERS: ", 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.GetMarketSummariesWithOpts(&bittrex.Options{
ConnTimeout: time.Second * 30,
})
if err != nil {
fmt.Println("ERROR OCCURRED: ", err)
}
Check out the tests (like this one) for an example of usage, but most of the times it will be as simple as the code above.
The API limits are unknown at the moment but there is an important note, came from resolving a test error:
Due to the Bittrex anti DDoS System (Cloudflare) it’s not possible to perform more than one request per second (otherwise it will be cached, resulting in error like the one described in Issue #18
)
I publicly thank @mastrolinux, which helped me in the discovery process of this (let’s call it) bug.
Golang Bittrex API v2.0.
This wiki has been provided to you by The Bot Guy <[email protected]>
Please check out the license (GPLv3) and respect it.