This is a Binance Go language sdk that uses a method similar to HuobiRDCenter/huobi_Golang
Please make sure you have read the Binance API document before continuing.
You are very welcome to submit issues or pull requests to share with this project to make the project more perfect
-
spot/client/wallet.go:Line602
WAPIAssetDetail()
The result types returned by minWithdrawAmount and withdrawFee are sometimes inconsistent, leading to running bugs. Currently, it has been parsed as interface{}. It is recommended to use this method of SAPI instead of this method.
-
spot/client/market.go:Line185
GetCandlestick()
It is not recommended using this method, this method may have type errors, please use websocket subscription to obtain data.
The following table shows the functions included in this SDK
Category | Client | Access Type |
---|---|---|
Common | System Status | RESTful API |
System Status (SAPI) | RESTful API | |
Test Connectivity | RESTful API | |
Check ServerTime | RESTful API | |
Wallet | All Coin's Information | RESTful API |
Daily Account Snapshot | RESTful API | |
Disabled/Enabled Fast Withdraw | RESTful API | |
Withdraw (SAPI) | RESTful API | |
Withdraw | RESTful API | |
Deposit History(supporting network) | RESTful API | |
Deposit History | RESTful API | |
Withdraw History(supporting network) | RESTful API | |
Withdraw History | RESTful API | |
Deposit Address(supporting network) | RESTful API | |
Deposit Address | RESTful API | |
Account Status | RESTful API | |
Account Status (SAPI) | RESTful API | |
Account API Trading Status | RESTful API | |
Account API Trading Status (SAPI) | RESTful API | |
DustLog | RESTful API | |
DustLog (SAPI) | RESTful API | |
Dust Transfer | RESTful API | |
Asset Dividend Record | RESTful API | |
Asset Detail | RESTful API | |
Asset Detail (SAPI) | RESTful API | |
Trade Fee | RESTful API | |
Trade Fee (SAPI) | RESTful API | |
User Universal Transfer | RESTful API | |
Query User Universal Transfer History | RESTful API | |
Market | Order Book | RESTful API |
Recent Trades List | RESTful API | |
Old Trade Lookup | RESTful API | |
Aggregate Trade | RESTful API | |
Candlestick | RESTful API | |
Current Average Price | RESTful API | |
24h Ticker Price Change | RESTful API | |
Symbol Price Ticker | RESTful API | |
Symbol Order Book Ticker | RESTful API | |
Aggregate Trade | WebSocket | |
Trade | WebSocket | |
Candlestick | WebSocket | |
Individual Symbol Mini Ticker | WebSocket | |
All Market Mini Tickers | WebSocket | |
Individual Symbol Ticker | WebSocket | |
All Market Tickers | WebSocket | |
Individual Symbol Book Ticker | WebSocket | |
All Book Tickers | WebSocket | |
Partial Book Depth | WebSocket | |
Diff. Book Depth | WebSocket | |
Trade | Test New Order | RESTful API |
New order | RESTful API | |
Cancel order | RESTful API | |
Cancel all order | RESTful API | |
Query order | RESTful API | |
Current open orders | RESTful API | |
All orders | RESTful API | |
New OCO | RESTful API | |
Cancel OCO | RESTful API | |
Query OCO | RESTful API | |
Query all OCO | RESTful API | |
Query Open OCO | RESTful API | |
Account Information | RESTful API | |
Account Trade List | RESTful API |
Category | Client | Access Type |
---|---|---|
Market | Aggregate Trade | WebSocket |
Market Price | WebSocket | |
All Market Price | WebSocket | |
Kline/Candlestick | WebSocket | |
Continuous Candlestick | WebSocket | |
Individual Symbol Mini Ticker | WebSocket | |
All Market Mini Tickers | WebSocket | |
Individual Symbol Ticker | WebSocket | |
All Book Tickers | WebSocket | |
Liquidation Order | WebSocket | |
All Market Liquidation Orders | WebSocket | |
Partial Book Depth | WebSocket | |
Diff. Book Depth | WebSocket | |
BLVT Info | WebSocket | |
BLVT NAV Kline/Candlestick | WebSocket | |
Composite Index Symbol | WebSocket |
Below are some examples of usage
Examples of user transfers in the universal
package spotclient
import (
binance "github.com/dirname/Binance"
"github.com/dirname/Binance/config"
"github.com/shopspring/decimal"
"reflect"
"testing"
"time"
)
func init() {
logger.Enable(false)
walletClient = spotclient.NewWalletClient(config.SpotRestHost, config.AppKey, config.AppSecret)
}
func universalTransfer() {
response, err := walletClient.UniversalTransfer("UMFUTURE_MAIN", "USDT", "10", 0)
if err != nil {
logger.Error("universalTransfer err: %s", err.Error())
}
switch response.(type) {
case model.APIErrorResponse:
logger.Info("universalTransfer API error: %v", response.(model.APIErrorResponse))
case spotclient.UniversalTransferResponse:
logger.Info("universalTransfer: %v", response.(spotclient.UniversalTransferResponse))
default:
logger.Info("universalTransfer Unknown response: %v", response)
}
}
Take the Kline of the USDⓈ-M Futures as an example
package main
import (
"fmt"
"github.com/dirname/Binance/futures/usdt/websocket/market"
logger "github.com/dirname/Binance/logging"
"github.com/dirname/Binance/model"
)
func main() {
client := futuresusdt.NewUSDTFuturesCandlestickWebsocketClient("btcusdt@kline_1m")
client.SetHandler(func() {
client.Subscribe(123, "btcusdt@kline_1m", "btcusdt@kline_5m")
client.SetCombined(true, 123)
}, func(response interface{}) {
switch response.(type) {
case futuresusdt.CandlestickResponse:
logger.Info("Candlestick Response: %v", response.(futuresusdt.CandlestickResponse))
case futuresusdt.CandlestickCombinedResponse:
logger.Info("CandlestickCombinedResponse: %v", response.(futuresusdt.CandlestickCombinedResponse))
case model.WebsocketCommonResponse:
logger.Info("Websocket Response: %v", response.(model.WebsocketCommonResponse))
case model.WebsocketErrorResponse:
logger.Info("Websocket Error Response: %v", response.(model.WebsocketErrorResponse))
default:
logger.Info("Unknown Response: %v", response)
}
})
client.Connect(true)
fmt.Scanln()
client.Unsubscribe(123, "btcusdt@kline_1m", "btcusdt@kline_5m")
client.Close()
logger.Info("Client closed")
}
This SDK is for personal use and has not been officially produced. They are only used to help users become familiar with API endpoint. Please use it with caution, and expand the R&D according to your own situation.
In addition, the performance and stability of this sdk need to be tested by yourself, and the loss due to performance or stability shall be borne by you