Skip to content

A go library for consuming Binance Websocket Market Streams

License

Notifications You must be signed in to change notification settings

yozel/binancestream

Repository files navigation

binancestream

A go library for consuming Binance Websocket Market Streams

This library handles network failures by automatically reconnecting to the websocket.

Usage

bs := binancestream.New(nil)
defer bs.Close()

var err error

err = bs.Subscribe("btcusdt@kline_1m", func(cs binancestream.CombinedStream) {
    fmt.Printf("Stream name: %s, Data: %s\n", cs.Name, cs.Data)
})
if err != nil {
    log.Fatal(err)
}

err = bs.Subscribe("ethusdt@kline_1m", func(cs binancestream.CombinedStream) {
    fmt.Printf("Stream name: %s, Data: %s\n", cs.Name, cs.Data)
})
if err != nil {
    log.Fatal(err)
}

bs.Wait()

If you want to find stream names to subscribe, you can find them here: https://binance-docs.github.io/apidocs/spot/en/#websocket-market-streams

About

A go library for consuming Binance Websocket Market Streams

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages