https://github.com/iowar/poloniex
Poloniex API in Go
https://github.com/iowar/poloniex
go poloniex poloniex-api
Last synced: 7 months ago
JSON representation
Poloniex API in Go
- Host: GitHub
- URL: https://github.com/iowar/poloniex
- Owner: iowar
- License: mit
- Created: 2017-12-24T19:10:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-18T22:54:56.000Z (over 5 years ago)
- Last Synced: 2024-06-19T05:41:18.983Z (about 1 year ago)
- Topics: go, poloniex, poloniex-api
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 15
- Watchers: 6
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Poloniex API GO
[](https://godoc.org/github.com/iowar/poloniex)Poloniex Push, Public and Trading APIs.
# Install
~~~sh
$ go get -u github.com/iowar/poloniex
~~~# APIs
~~~go
import polo "github.com/iowar/poloniex"
~~~
## Push Api
Create websocket client.
#### NewWSClient()
~~~go
ws, err := polo.NewWSClient()
if err != nil {
return
}
~~~
* Push Api Methods
* SubscribeTicker()
* SubscribeMarket()
* UnsubscribeTicker()
* UnsubscribeMarket()### Ticker
#### SubscribeTicker()
~~~go
err = ws.SubscribeTicker()
if err != nil {
return
}
for {
fmt.Println(<-ws.Subs["TICKER"])
}
~~~
#### UnsubscribeTicker()
~~~go
err = ws.SubscribeTicker()
go func() {
time.Sleep(time.Second * 10)
ws.UnsubscribeTicker()
}()
for {
fmt.Println(<-ws.Subs["TICKER"])
}
~~~### OrderDepth, OrderBook and Trades
#### SubscribeMarket()
~~~go
err = ws.SubscribeMarket("USDT_BTC")
if err != nil {
return
}
for {
fmt.Println(<-ws.Subs["USDT_BTC"])
}
~~~
#### UnsubscribeMarket()
~~~go
err = ws.SubscribeMarket("USDT_BTC")
if err != nil {
return
}
go func() {
time.Sleep(time.Second * 10)
ws.UnsubscribeMarket("USDT_BTC")
}()
for {
fmt.Println(<-ws.Subs["USDT_BTC"])
}
~~~~### Examples
* See [Push Api Examples](https://github.com/iowar/poloniex/tree/master/examples/push)## Public Api
~~~go
poloniex, err := polo.NewClient(api_key, api_secret)
~~~
* Public Api Methods
* GetTickers()
* Get24hVolumes()
* GetOrderBook()
* GetPublicTradeHistory()
* GetChartData()
* GetCurrencies()
* GetLoanOrders()
#### Example
~~~go
resp, err := poloniex.GetTickers()
if err != nil{
panic(err)
}
fmt.Println(resp)
~~~
* See [Public Api Examples](https://github.com/iowar/poloniex/tree/master/examples/public)## Trading Api
~~~go
const (
api_key = ""
api_secret = ""
)
~~~
~~~go
poloniex, err := polo.NewClient(api_key, api_secret)
~~~* Trading Api Methods
* GetBalances()
* GetCompleteBalances()
* GetAccountBalances()
* GetDepositAddresses()
* GenerateNewAddress()
* GetOpenOrders()
* GetAllOpenOrders()
* CancelOrder()
* GetTradeHistory()
* GetTradesByOrderID()
* GetOrderStat()
* Buy()
* Sell()#### Example
~~~go
resp, err := poloniex.Buy("btc_dgb", 0.00000099, 10000)
if err != nil{
panic(err)
}
fmt.Println(resp)
~~~
* See [Trading Api Examples](https://github.com/iowar/poloniex/tree/master/examples/trading)License
----
[MIT](https://github.com/iowar/poloniex/blob/master/LICENSE)