Code Monkey home page Code Monkey logo

binance-us-api-docs's People

Contributors

48clubian avatar adderall-prozac avatar alexding-ba avatar bandabh avatar binanceapitest avatar ctn-dev avatar daikiojm avatar datatypevoid avatar doomhz avatar gam-phon avatar geekdadley avatar gerryhyh avatar imranm avatar jayarjo avatar joeyshen714 avatar lynnwork avatar markusgalant avatar nadirzenith avatar ninj0r avatar peterzan888 avatar rolaus avatar saxicek avatar shijun1988 avatar tigerweichao avatar ttodua avatar wayneadams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binance-us-api-docs's Issues

Staking API

It looks like it is impossible to get staking balances on binance.us. It would be great if there was an API for this, just like binance.com

Error code -1100 for asset dust conversions

Dust conversions are not supported in the dashboard, but I was hoping they would be supported in the API. Following the documentation for the regular Binance API, I found the endpoint /sapi/v1/asset/dust. Which responds on the BinanceUS API, but seems to be really inconsistent. It doesn't actually convert the dust and returns random errors without changing how it's being called. Currently getting the error "Illegal characters found in a parameter" with code -1100.

Here is how I'm calling the endpoint from a shell script:

API_KEY="..."
API_SECRET="..."
ASSET="ETH"

TS="$(date +%s)000"
SIG=$(echo -n "asset=$ASSET&timestamp=$TS" | openssl dgst -sha256 -hmac "$API_SECRET")

curl https://api.binance.us/sapi/v1/asset/dust -H "x-mbx-apikey: $API_KEY" -d "asset=$ASSET&timestamp=$TS&signature=$SIG"

websocket for Binance US

I have the most primitive python code to see if I can use the websocket for getting data but it doesn't seem to be working properly.
Here's the code:

import websocket, json, pprint

SOCKET = "wss://stream.binance.us:9443/ws/ethusd@kline_1m"

def on_open(ws):
print('opened connection')

def on_close(ws):
print('closed connection')

def on_error(ws, error):
print(error)

def on_message(ws, message):
print('received message')
json_message = json.loads(message)
pprint.pprint(json_message)

ws = websocket.WebSocketApp(SOCKET, on_open=on_open, on_close=on_close, on_error=on_error, on_message=on_message)
ws.run_forever()

The result is the following:
[WinError 10061] No connection could be made because the target machine actively refused it
on_close() takes 1 positional argument but 3 were given

Get order endpoint price is always 0

I've placed a few live orders and when I query them to get fill info, the price always shows up as 0.0000 despite the fact that status is FILLED and executed_quantity matches orig_quantity.

So I do not know at what price the order was filled without going into Binance.us website.

Inconsistent api/v3/myTrades response

I tried to pull my historical trade history of a symbol using api/v3/myTrades, but there are 3 possible responses I can get from the code:

  1. An empty list
  2. Full trade history
  3. Trade history missing the first week

I already have fromID = 0. And to replicate the problem,use api/v3/myTrades with any owned assets, do it multiple times, and check the length of the responce. In my test, it is always the 3 outcomes I listed above. Is there a solution to this problem?

Read only API key is not read only!

Issue

There is quite a big security risk regarding your API...
Read only API keys aren't actually read only and can still create/delete orders.

Steps to reproduce

  • Create a read only API key
  • Try to create a new order using the api/v3/order or api/v3/order/test endpoint

What should happen

Should return an error saying the key doesn't have the required permissions like the normal Binance API does.

body: {
    code: -2015,
    msg: 'Invalid API-key, IP, or permissions for action.'
},

Correctly constructed JSON objects unable to be read by binanceAPI. Error code 3 returned

This JSON object

var paramJSON = {
	"method": "SUBSCRIBE",
	"params": [
		"btcusd@kline_1m",
		"ethusd@kline_1m",
		"solusd@kline_1m",
		"dogeusd@kline_1m",
		"adausd@kline_1m",
		"vetusd@kline_1m",
		"bnbusd@kline_1m"
	],
	"id": "10"
}

is unable to be read by the Binance parser, despite being a valid JSON object. I have also tried sending the same message with the parenthesis removed from the ID, but that does not work either.

I am using the inbuilt javascript WebSocket class to handle my class, and I am sending this message to a connected stream using this code:
stream.send(paramJSON)

Furthermore, I have also tried sending the example message from this project's documentation, but that is also returned with error code 3.

var paramJSON = {
  "method": "SUBSCRIBE",
  "params": [
    "btcusdt@aggTrade",
    "btcusdt@depth"
  ],
  "id": 1
}

I am certain that I am sending these JSON files over a valid connection. What could be going on here?

WAPI Deposit and Withdrawals history endpoints returning 500's

WAPI endpoints are returning 500 error codes:

curl 'https://api.binance.us/wapi/v3/depositHistory.html?startTime=1584262070299&endTime=1592038070299&timestamp=1592038060243&recvWindow=60000&signature=6c70bd0d3e2f91e5e115e016c4483d4c479c72a5c3608050c7420d3820373955' -H 'X-MBX-APIKEY: REDACTED' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.130 Electron/7.1.11 Safari/537.36' -H 'Referer: http://localhost:3000/main.93533e07d2c2e0d35407.worker.js' --compressed

{"code":-1100,"msg":"Illegal characters found in a parameter."}

As per (https://docs.binance.us/?python#get-server-time) I am testing this here code for the API.

import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

def get_binanceus_signature(data, secret):
postdata = urllib.parse.urlencode(data)
message = postdata.encode()
byte_key = bytes(secret, 'UTF-8')
mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
return mac

def binanceus_request(uri_path, data, api_key, api_sec):
headers = {}
headers['X-MBX-APIKEY'] = api_key
signature = get_binanceus_signature(data, api_sec)
params={
**data,
"signature": signature,
}
req = requests.get((api_url + uri_path), params=params, headers=headers)
return req.text

api_key='my_key'
secret_key='my_secret'

uri_path = "/sapi/v1/system/status"
data = {
"timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

But I keep receiving this error when I run the code.
GET /sapi/v1/system/status: {"code":-1100,"msg":"Illegal characters found in a parameter."}

Wallet Endpoint - Withdraw/Deposit History

I am trying to get withdraw history but /sapi/v1/capital/withdraw/history is not working for me on BinanceUS.
i also tried api/v3/withdrawHistory.html in both cases I get illegal character error: Illegal characters found in parameter 'ip'; legal range is '^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$'. any ideas?

`MIN_NOTIONAL` is one of several values that define a minimum quantity required in an order for any given crypto. In addition to it, you will need to ensure your order quantity is equal or greater than `LOT_SIZE`. Finally, your order must be within the `LOT_SIZE => stepSize` value. Ex: given that `stepSize = 1`, your order quantity must be a whole number.

          `MIN_NOTIONAL` is one of several values that define a minimum quantity required in an order for any given crypto. In addition to it, you will need to ensure your order quantity is equal or greater than `LOT_SIZE`. Finally, your order must be within the `LOT_SIZE => stepSize` value. Ex: given that `stepSize = 1`, your order quantity must be a whole number. 

These values can be found in the "filters" array returned by the GET /api/v3/exchangeInfo endpoint.

If you'd rather understand what I'm saying as code, here is a full ruby example that I quickly threw together:

      symbol = 'ADABTC'
      info = Binance::Api.exchange_info!( # GET /api/v3/exchangeInfo
        api_key: user.binance_api_token,
        api_secret_key: user.binance_api_secret,
      )[:symbols].find { |e| e[:symbol] == symbol }
      raise Binance::Api::Error.new "#{symbol} not found in exchange info" if info.nil?
      min_lot_size = -> do
        filter = info[:filters].find { |f| f[:filterType] == "LOT_SIZE" }
        raise Binance::Api::Error.new "LOT_SIZE not found in exchange info for #{symbol}" if filter.nil?
        filter[:minQty].to_d
      end
      min_notional = -> do
        filter = info[:filters].find { |f| f[:filterType] == "MIN_NOTIONAL" }
        raise Binance::Api::Error.new "MIN_NOTIONAL not found in exchange info for #{symbol}" if filter.nil?
        filter[:minNotional].to_d
      end
      step_size = -> do
        filter = info[:filters].find { |f| f[:filterType] == "LOT_SIZE" }
        raise Binance::Api::Error.new "LOT_SIZE not found in exchange info for #{symbol}" if filter.nil?
        filter[:stepSize].to_d
      end
      quantity = [
        (min_notional.call / current_price.to_d) + step_size.call - ((min_notional.call / current_price.to_d) % step_size.call),
        min_lot_size.call,
      ].max

The result of this code is a quantity variable that represents the absolute minimum quantity required for an order to succeed. Hope this helps!

Disclaimer: I'm the author of binance-ruby.

Originally posted by @0xjmp in #10 (comment)

Trade Fee returns no data

When doing the following request: GET /wapi/v3/tradeFee.html (HMAC SHA256)
The following response is returned:

{
  "tradeFee": [],
  "success": true
}

Is this expected behaviour?
Why would no tradeFee be returned?
Is there a user permission missing to allow this endpoint?

Thanks

Partial Book Depth Stream Identification

Unlike other stream types, partial book depth does not include a symbol property. When subscribing to multiple partial book depth streams and using non-combined stream events, there is no identifying information which could be used to reliably relate an event to the appropriate symbol.

Cloudfront error on get order and get account

GET /api/v3/order
GET /api/v3/account

Are returning a cloudfront error:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>

<HEAD>

	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
	<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD>

<BODY>
	<H1>403 ERROR</H1>
	<H2>The request could not be satisfied.</H2>
	<HR noshade size="1px">
	Bad request.
	We can't connect to the server for this app or website at this time. There might be too much traffic or a
	configuration error. Try again later, or contact the app or website owner.
	<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
	<BR clear="all">
	<HR noshade size="1px">
	<PRE>
Generated by cloudfront (CloudFront)
Request ID: JneTbqzjzLynhUkCVUQA5_zXqw314Ju3tUzAGmxevNgnX7h8B5Kw-A==
</PRE>
	<ADDRESS>
	</ADDRESS>
</BODY>

</HTML>

/api/v3/myTrades returns empty list

I am trying to get a list of all my previous trades so I can compute my average buying price per symbol.
I am able to use endpoints like /account, /ticker/price etc. with the API key and secret I generated. However, /api/v3/myTrades always returns an empty list regardless of the symbol I pass to it (I have tried 'BTCUSD', 'DOGEUSD', 'USDTUSD' etc.).

Am I missing something?

P.S.: I am calling these endpoints through python-binance since I found it easier to create the client using that package.

Python Errors related to Klines

Using Python Binance Version 0.7.11 and am getting these error codes after about two minutes of querying and using Kline intervals of 5 minutes or more. Appear to be data issues and not sure where/how to change the modules. Has anyone received these error codes, know the fix or where i can fine the information to make the fixes? Many thanks for any information you can provide!!!

Error Messages

File "pandas_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\hashtable_class_helper.pxi", line 4554, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas_libs\hashtable_class_helper.pxi", line 4562, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 4

indexing.py", line 889, in __getitem__return self._getitem_tuple(key)
indexing.py", line 1060, in _getitem_tuple
return self._getitem_lowerdim(tup)indexing.py", line 807, in _getitem_lowerdim
section = self._getitem_axis(key, axis=i)indexing.py", line 1124, in _getitem_axis
return self._get_label(key, axis=axis)indexing.py", line 1073, in _get_label
return self.obj.xs(label, axis=axis)generic.py", line 3724, in xs return self[key]
frame.py", line 3024, in getitem indexer = self.columns.get_loc(key)
indexes\base.py", line 3082, in get_loc raise KeyError(key) from err
KeyError: 4

Does the library binance-connector-node work for binance-us ?

Hi, I like to use the binance-us api for integration of some tokens of binance-us into a wallet, Does the library binance-connector-node work for or is compatible with binance-us ? I am asking because the library is from binance, not binance-us.

Thanks

New Order/Trade Question

Hello,
I am simplly just trying to create a new trade Buy/Sell on the orderbook.
I got past a few mistakes I had but now im getting:
"Filter failure: MIN_NOTIONAL" -1013
I'm not sure what this error is for.

I'm trying to do a Stop-Limit Trade.
I would like to buy or sell x amount of crypto at y price.

Here is my PlaceOrderAsync()

 using (var client = new BinanceClient())
                    {
var orderResult = await client.PlaceOrderAsync(
                                                                    stopOrder.TradeSymbol,
                                                                    OrderSide.Sell,
                                                                    OrderType.StopLossLimit,
                                                                    quantity: stopOrder.CryptoAmount,
                                                                    null,
                                                                    null,
                                                                    price: stopOrder.LimitPrice,
                                                                    timeInForce: TimeInForce.GoodTillCancel,
                                                                    stopPrice: stopOrder.StopPrice,
                                                                    orderResponseType: OrderResponseType.Result);
}

Here is another 1 i tried.
//var orderResult = await client.PlaceOrderAsync(
                        //                                            stopOrder.TradeSymbol, 
                        //                                            OrderSide.Sell, 
                        //                                            OrderType.StopLossLimit, 
                        //                                            stopOrder.CryptoAmount,                             
                        //                                            null, 
                        //                                            null, 
                        //                                            stopOrder.LimitPrice, 
                        //                                            TimeInForce.GoodTillCancel,
                        //                                            stopOrder.StopPrice, 
                        //                                            null,
                        //                                            OrderResponseType.Full);

Market Price Websocket not recieving any data all of a sudden

Title, other sockets such as Kline, Depth and Ticker all are fine but the market price went dead. Any ideas as to why this one is quiet? I am getting no errors when creating the socket. I am doing a lot of connecting and disconnecting as I am debugging my code but have never had this issue before

binance rest api place TRAILING_STOP_MARKET order activatePrice being ignored

i have a function to set a TRAILING_STOP_MARKET order
the function works the order being place but my activatePrice is not the number am sending
i set it to 0.9918 and on binance it set it to 0.9841
i try to change the number of activatePrice and the callbackRate it did not seem to have an effect on the activatePrice
i used this docs to make the function:https://binance-docs.github.io/apidocs/futures/en/#query-current-open-order-user_data
anyone know why my activateprice being ignored or being set to value different then what am sending
heres the function:

def place_stop_trail_order(symbol,side,quanitity,callbackrate,activateprice):
    symbol =symbol  # Replace with the trading pair symbol
    side = side  # 'BUY' or 'SELL'
    quantity = quanitity  # Replace with the quantity
    callbackRate =callbackrate  # Price rate for trailing stop
    activatePrice = activateprice  # Activation price for trailing stop
    reduceOnly = True  # Set to True to make the order reduce-only
    trailType = 'TRAILING_STOP_MARKET'  # Type of trailing stop

    
    endpoint="/fapi/v1/order"
    timestamp = int(time.time() * 1000)
    params = {
        'symbol': symbol,
        'side': 'SELL' if side == 'long' else 'BUY',
        'quantity': quantity,
        'callbackRate': callbackRate,
        'activatePrice': activatePrice,
        'reduceOnly': reduceOnly,
        'type': trailType,
        'timestamp': timestamp,
    }
    query_string = '&'.join([f"{key}={params[key]}" for key in params])
    signature = hmac.new(api_secret.encode(), query_string.encode(), hashlib.sha256).hexdigest()

    headers = {
        'X-MBX-APIKEY': api_key,
    }

    data = {
        'symbol': symbol,
        'side': 'SELL' if side == 'long' else 'BUY',
        'quantity': quantity,
        'callbackRate': callbackRate,
        'activatePrice': activatePrice,
        'reduceOnly': reduceOnly,
        'type': trailType,
        'timestamp': timestamp,
        'signature': signature,
    }

    response = requests.post(base_url + endpoint, headers=headers, data=data)
    if response.status_code == 200:
        print("TRAILING_STOP order placed successfully!")
        print(response.json())
        data=response.json()
        return data
    else:
        print(f"Failed to place TRAILING_STOP order. Status code: {response.status_code}")
        print(response.json())
        data=response.json()
        return data

values:

'symbol':'TOMOUSDT'
'side':'SELL'
'quantity':24.0
'callbackRate':0.1
'activatePrice':0.9918
'reduceOnly':True
'type':'TRAILING_STOP_MARKET'
'timestamp':1693069060070

AssetDetail error 500

Hi,

AssetDetail queries of the wapi return a 500 error code.
The same request works on Binance.com

Withdraw/Deposit (crypto) endpoints ignore 'startTime', 'endTime'. No Fiat endpoints

I'm also noting the lack of documentation for the withdrawal and deposit (crypto) for this API.

Trying /sapi/v1/capital/deposit/hisrec for crypto deposit information and /sapi/v1/capital/withdraw/history for crypto withdrawals.

They both seem to ignore timestamps being sent to bracket a timeframe and if over 90 days is specified as the span, the endpoints blow up with bad request errors.

The fiat endpoint /sap1/v1/fiat/orders seems to not even be found any more.

What's going on, Binance?

binance.us dust conversion error "code":-5004

Hello, I am receiving this error when I try to convert any asset's dust:
{"code":-5004,"msg":"The residual balances of the ADA have exceeded 0.001BTC, Please re-choose."}

If I check my balance using the same API I get this:
{"asset":"ADA","free":"0.06300000","locked":"0.00000000"}

As you can see, this is way below the maximum amount. Is dust conversion not supported on binance.us?

Python Issue All orders (USER_DATA)

When I tried to fetch order data for a symbol some of market limit sell price shows "0.0000"

image

for example I'm sharing one of my order details which shows price as 0.000

Facing symbol issue

for some of the symbols I am getting an error
klines:
error: Symbol is not valid

for "BTCUSDT" gettting an issue same working for "BNB_BTC.B-918"

Historical Trades Error -2014

The /historicalTrades endpoint is not listed as requiring authentication via HMAC SHA256 but I'm getting error -2014 indicating an API key is missing. Will this endpoint be available without authentication? Thanks!

code: -1135, msg: 'Invalid account status.'

I recently created an API key for futures trading but hit this error code when trying to buy using the API key. I've verified I can successfully buy futures through the web app and I've also verified the code I wrote works for other people's API keys.

Could we get some clarity as to exactly what this status code entails and how to debug it?

Sample code:

async function smallBuy() {
    const Binance = require("node-binance-api");
    const signedBinance = new Binance().options({
        APIKEY: "",
        APISECRET: "",
        useServerTime: true
    });

    const test1 = await signedBinance.futuresBuy("BNBUSDT", 0.1)
    console.log(test1);

    const balance = await signedBinance.balance();
    const test2 = Object.keys(balance).map(_ => { return { [_]: Number(balance[_].available) } }).filter(_ => Object.values(_)[0] > 0);
    console.log(test2);
}

‘Withdraw unavailable due to risk management’

Oh yeah, Binance.US is quick to take their cut of your finances from their 'minimum' deposit/withdraw/transfer requirements. Yet can't even move my assets out of here to an actual function exchange. Doesn't matter if I try to withdraw crypto, or transfer, or even try to cash out and go ach deposit, same error message every time. And the only word so far is, 'we are overwhelmed with support tickets, we will merge all of your request into one, PLEASE DO NOT CONTACT US/ create any more tickets for this issue. We will get to you when we find out how to run customer support' pathetic.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.