Go library for Kraken Websocket and REST API
go get github.com/aopoltorzhicky/go_kraken/websocket
Now only Public API realized. Private API is under developing.
go get github.com/aopoltorzhicky/go_kraken/rest
To learn how you can use the package read examples.
For quick start read the one below:
package main
import (
"log"
ws "github.com/aopoltorzhicky/go_kraken/websocket"
)
func main() {
c := ws.New(false)
err := c.Connect()
if err != nil {
log.Fatal("Error connecting to web socket : ", err)
}
err = c.Ping()
if err != nil {
log.Fatal(err)
}
// subscribe to BTCUSD, XLMUSD, ADACAD spread
err = c.SubscribeSpread([]string{ws.BTCUSD, ws.XLMUSD, ws.ADACAD})
if err != nil {
log.Fatal(err)
}
for obj := range c.Listen() {
switch obj.(type) {
case error:
log.Printf("channel closed: %s", obj)
case ws.DataUpdate:
data := obj.(ws.DataUpdate)
log.Printf("MSG RECV: %#v", data)
default:
}
}
}
To learn how to use REST API read example below:
package main
import (
"log"
"github.com/aopoltorzhicky/go_kraken/rest"
)
func main() {
api := rest.New("", "")
spread, err := api.GetSpread("ADAETH", 0)
if err != nil {
log.Fatalln(err)
}
log.Println(spread)
t, err := api.Time()
if err != nil {
log.Fatalln(err)
}
log.Println(t)
}