Skip to content

Go library for Kraken Websocket and REST API

License

Notifications You must be signed in to change notification settings

oomag/go_kraken

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status codecov Codacy Badge

Kraken Go

Go library for Kraken Websocket and REST API

Installation Websocket package

go get github.com/aopoltorzhicky/go_kraken/websocket

Installation REST API package

Now only Public API realized. Private API is under developing.

go get github.com/aopoltorzhicky/go_kraken/rest

Usage

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)
}

About

Go library for Kraken Websocket and REST API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%