Skip to content

jaztec/go-binance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status License MIT Go Report Card codecov GoDoc

Go Binance API SDK

Goal

This library aims to provide some clean endpoints allowing a user to interact seamlessly and easily with the Binance V3 REST and Websocket API's.

Examples

You can find examples inside the examples directory in the repository.

As you can see setting up an instance is easy. The following snippet will give you an overview of your account assets:

package main

import (
	"fmt"
	"flag"
	"github.com/jaztec/go-binance"
)

func main() {
	key := flag.String("key", "none", "The API key provided by Binance")
	secret := flag.String("secret", "none", "The secret that belongs to the API key")
	flag.Parse()

	b, err := binance.NewAPICaller(binance.APIConfig{
		Key:    *key,
		Secret: *secret,
	})
	if err != nil {
		panic(err)
	}

	a, err := b.Account()
	if err != nil {
		panic(err)
	}

	fmt.Println(a)
}

Interfaces

The SDK consists of a couple of interfaces. The most important are the API and Streamer. These interfaces expose the fundamentals to talk with the Binance API. These interfaces however are also as clean as possible.

To actually make use of the implemented function calls the APICaller and StreamCaller interfaces have been created.

Missing methods

The SDK for the moment only exposes a couple of endpoints used for my own applications. However, you can easily use the Request method to formulate your own request or implement a function and send in a pull request.

package main

import (
	"fmt"
	"github.com/jaztec/go-binance"
	"net/http"
)

func main() {
	a, err := binance.NewAPI(binance.APIConfig{})
	if err != nil {
		panic(err)
	}

	p := binance.NewParameters(1)
	p.Set("symbol", "ETHBTC")

	res, err := a.Request(http.MethodGet, "/api/v3/avgPrice", p)
	if err != nil {
		panic(err)
	}

	fmt.Println(res)
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published