Skip to content

hhh0pE/poloniex-api

Repository files navigation

Go Poloniex API wrapper

This API should be a complete wrapper for the Poloniex api, including the public, private and websocket APIs.

Install

go get -u github.com/pharrisee/poloniex-api

Usage

To use create a copy of config-example.json and fill in your API key and secret.

{
    "key":"put your key here",
    "secret":"put your secret here"
}

You can also pass your key/secret pair in code rather than creating a config.json.

Examples

Public API

package main

import (
	"log"

	"github.com/k0kubun/pp"
	poloniex "gitlab.com/wmlph/poloniex-api"
)

func main() {
	p := poloniex.NewPublicOnly()
	ob, err := p.OrderBook("BTC_ETH")
	if err != nil {
		log.Fatalln(err)
	}
	pp.Println(ob.Asks[0], ob.Bids[0])
}

Private API

package main

import (
	"fmt"
	"log"

	"gitlab.com/wmlph/poloniex-api"
)

func main() {
	p := poloniex.New("config.json")
	balances, err := p.Balances()
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("%+v\n", balances)
}

Websocket API

package main

import (
	"log"

	poloniex "github.com/pharrisee/poloniex-api"

	"github.com/k0kubun/pp"
)

func main() {
	p := poloniex.NewWithCredentials("Key goes here", "secret goes here")
	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)

	ch := p.SubscribeOrder("BTC_ETH")
	for orders := range ch {
		pp.Println(orders)
	}
}

About

A Go wrapper to the Poloniex API

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages