golang-bittrex-api

module
v0.0.0-...-27a8629 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0

README

= THIS PROJECT IS NOW ARCHIVED

You can use link:https://github.com/toorop/go-bittrex[toorop/go-bittrex library] to connect to Bittrex API.

= golang-bittrex-api
The Bot Guy <thebotguy@protonmail.com>

image:https://travis-ci.org/thebotguys/golang-bittrex-api.svg?branch=master["Build Status", link="https://travis-ci.org/thebotguys/golang-bittrex-api"]

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

== Getting the package

[source, bash]
----
$ go get github.com/thebotguys/golang-bittrex-api/bittrex
----

== Calling the API functions
For *Public API* is simple:
[source, go]
----
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:
[source, go]
----
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)
}
----

You are *strongly* advised to check if the API is online at the start of your program, with the following code:
[source, go]
----
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`:
[source, go]
----
// 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 link:https://github.com/thebotguys/golang-bittrex-api/blob/master/bittrex/public_test.go[this] one) for an example of usage, but _most of the times_ it will be as simple as the code above.

== API Limits
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 link:https://github.com/thebotguys/golang-bittrex-api/issues/18[`Issue #18`])

I publicly thank link:https://github.com/mastrolinux[*@mastrolinux*], which helped me in the discovery process of this _(let's call it) bug_.

== Socket API
*Work in progress*

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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