binance / binance-api-postman Goto Github PK
View Code? Open in Web Editor NEWPostman collection for Binance Public API, including spot, margin, futures, etc.
License: MIT License
Postman collection for Binance Public API, including spot, margin, futures, etc.
License: MIT License
Hey,
I wanted to ask if there will be an API series part II since at the end of part one it says the next part will covering simple coding.
I'm tyring to follow the (very excellent) 'Binance API Series Pt. I – Spot Trading with Postman'.
Of course I did the steps for creating a test user (1610642226219045601), but still I get a '401 Unauthorized' error with the JSON-response below for several of the services that are described in the tutorial. Among the failing services are very relevant ones like /account and /order.
{
"code": -2015,
"msg": "Invalid API-key, IP, or permissions for action."
}
I'm guessing it has something to do with the signature that has to be filled in for these services? Postman is so kind as to generate these, but I can imagine this should be some fixed value, since it is supposed to "prove that we’re the account holder."?!
As you can see from the attached videos the /api/v3/openOrders returns wrong data during tests with postman.
As you can see in the video I have 3 open orders (both CHZEUR) and the api returns from 0 to 3 results each time I run it.
In the second video I have 1 CHZEUR order and 1 MATICEUR order, also in this case the api returns wrong values.
Hello,
I'm new to this API and I would like to know if someone knows how to get Historical User Data. I can't figure out how to get my Balance from a Week ago or a Month or a Year, because If I know the amount of BTC I had I can calculate my profit at a given time.
Thanks in advance
Harry
Open Interest Statistics (MARKET_DATA)
and more
https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-market_data
Noob here. Getting the error {"code":-1021,"msg":"Timestamp for this request is outside of the recvWindow."}
Running code from India:
#Importing the 2 libraries required
import time
import requests
#getting the timestamp
ts = time.time()
#remaining code generated from Postman using instructions on Binance academy post.
#The timestamp is adding dynamically ("+str(int(ts))+")
#replacing signature with somesignature in this issue only. My original code has the correct signature
url = "https://api.binance.com/api/v3/account?timestamp="+str(int(ts))+"&signature=somesignature"
payload={}
#replacing api key with somekey in this issue only. My original code has the correct api key. Same for session id.
headers = {
'Content-Type': 'application/json',
'X-MBX-APIKEY': 'somekey',
'Cookie': 'JSESSIONID=somesessionid'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
Seems that Long/Short Ratio API methods don't return all data what it needed, now it's returns only data from Long/Short columns, but it makes no sense, because it's always almost the same:
So only one accurate way is to get exactly ratio graph, which shows the correct data, so if we gets its longShortRatio
from API and can simply compare it with ratio overage value which is, as for 15m timeframe for example, is (1.08 + 1.20) / 2 = 1.14
But the problem is that API methods for this don't returns min and max ratio values for get its overage, I can get it from Futures Trade Data page and hardcode it in my code, but it's depends on timeframe and columns number, so unfortunately it's impossible. It will be great to add the ratio min and max value to the api methods like topLongShortPositionRatio
results to get its overage value to compare it with ratio value getting from API. Thanks in advance.
This request POST /sapi/v1/bnbBurn?spotBNBBurn=.... not work
The answer comes about an invalid parameter.
I am using the following code to request a given method:
`
class BH():
methods = {'bnbBurn': {'url': 'sapi/v1/bnbBurn', 'method': 'POST', 'private': True}}
def __init__(self, API_KEY, API_SECRET):
self.API_KEY = API_KEY
self.API_SECRET = bytearray(API_SECRET, encoding='utf-8')
self.shift_seconds = 0
def __getattr__(self, name):
def wrapper(*args, **kwargs):
kwargs.update(command=name)
return self.call_api(**kwargs)
return wrapper
def set_shift_seconds(self, seconds):
self.shift_seconds = seconds
def call_api(self, **kwargs):
command = kwargs.pop('command')
base_url ='https://api1.binance.com/'
if self.methods[command].get('futures'):
base_url = 'https://fapi.binance.com/'
api_url = base_url + self.methods[command]['url']
payload = kwargs
headers = {}
payload_str = urllib.parse.urlencode(payload)
if self.methods[command]['private']:
payload.update({'timestamp': int(time.time() + self.shift_seconds - 1) * 1000})
payload_str = urllib.parse.urlencode(payload).encode('utf-8')
sign = hmac.new(
key=self.API_SECRET,
msg=payload_str,
digestmod=hashlib.sha256
).hexdigest()
payload_str = payload_str.decode("utf-8") + "&signature="+str(sign)
headers = {"X-MBX-APIKEY": self.API_KEY, "Content-Type":"application/x-www-form-urlencoded"}
if self.methods[command]['method'] == 'GET' or self.methods[command]['url'].startswith('sapi'):
api_url += '?' + payload_str
response = requests.request(method=self.methods[command]['method'], url=api_url, data="" if self.methods[command]['method'] == 'GET' else payload_str, headers=headers)
if 'code' in response.text:
raise Exception(response.text)
return response.json()
bh = BH(c_api, c_secret)
result = bh.bnbBurn(spotBNBBurn = False, interestBNBBurn = False)
`
I get error as
{
"code": -2015,
"msg": "Invalid API-key, IP, or permissions for action, request ip: 101.80.21.205"
}
in collections Binance perpetual future API -> Account -> Account information
which send request as
curl --location --request GET 'https://testnet.binancefuture.com/fapi/v1/account?timestamp=1613652317700&signature=13d5684fbf8a50f52f87c72426a2e7925841912688456ce48b0d71f809cdfa6c' \
--header 'Content-Type: application/json' \
--header 'X-MBX-APIKEY: a2NQttwdUgdgfqzgXobwE4JUR9onDWK4basorZERDeZiDF2FZErlmJ3N3m7vM5q5'
but all the requests in the future API -> Market send success.
because I use the same binance-api-key and binance-api-secret for spot which I get from https://testnet.binance.vision/
so I wonder the future api have different secret key? or are there any other problems?
Json files are not imported by the latest versions of Postman
Hi!
Could you please add BSwap Endpoints to the collections List?
There are documented there: https://binance-docs.github.io/apidocs/spot/en/#bswap-endpoints
Thanks.
I just downloaded the binance api postman collection and imported it as requested (set api key, api secret and use correct environment).
The error -2008 is not documented here (https://binance-docs.github.io/apidocs/spot/en/#11xx-2xxx-request-issues) and the error "Invalid Api-Key ID." isn't helpful either to solve the problem.
Could you please help me figuring out what's the problem?
Bantu saya..
As per the release note of March 24th, there is a new parameter, which looks very useful https://binance-docs.github.io/apidocs/spot/en/#change-log. However it cannot be in the ExchangeInfo endpoint as it would need an authenticate call to retrieve the client order. Could you update the collection to demonstrate which endpoint returns this value?
{
"code": -1013,
"msg": "Filter failure: PERCENT_PRICE"
}
Postman recently launced Public Workspaces, with loads of features. Binance can leverage it to keep track of the APIs and the docs, meanwhile general public can test out those collections by forking it in their personal workspace. Do take a look at it. Felt it will be useful for you guys.
Blog Post: https://blog.postman.com/introducing-postman-public-workspaces/
Sample Workspace:https://www.postman.com/postman/workspace/postman-public-workspace/overview
What should we use as signature? The Secret Key?
I always get this error
"code": -1022,
"msg": "Signature for this request is not valid."
Hey when I make a request it always tells me that the server is ahead of my time, how can I fix it? Btw I'm a completely beginner so don't flame me haha
{{url}}/sapi/v1/capital/config/getall?timestamp=1616338278&signature={{signature}}
Hi,
I only suffer from this error when the price field is set to variable. If I enter the price manually, the buy order is placed without any problem. What may be the problem?
EDIT:
I can see the problem is in the signature when any field is set as a variable. So how to automate the processes if I have to enter all the fields manually?
{ "code": -1022, "msg": "Signature for this request is not valid." }
i set everything as well like binance api key and secret.
i check all of it.
X-MBX-APIKEY is true.
i can get every result as well at market and accout tabs like Account Trade List but when i try under of Order tab like All Orders i got an signature error.
Hello, I'm developing an application for my own use. I'm new to using API's, I'm using Postman to check outputs/responses without adding them to my application yet.
When I query for Deposit and Withdrawal history I'm getting this as response.
{
"code": -1022,
"msg": "Signature for this request is not valid."
}
Other queries work using my API and Secret keys.
Things I've tried:
Restricted my API to work only on my IP address
Enabled all possible API restrictions
Cleared the signature on my Postman environment
Please HALP. Thanks in advance
Getting error on some margin order queries.
{
"code": -1022,
"msg": "Signature for this request is not valid."
}
I'm tyring to follow the (very excellent) 'Binance API Series Pt. I – Spot Trading with Postman'.
Of course I did the steps for creating a test user (1610642226219045601), but still I get a '401 Unauthorized' error with the JSON-response below for several of the services that are described in the tutorial. Among the failing services are very relevant ones like /account and /order.
{
"code": -2015,
"msg": "Invalid API-key, IP, or permissions for action."
}
I'm guessing it has something to do with the signature that has to be filled in for these services? Postman is so kind as to generate these, but I can imagine this should be some fixed value, since it is supposed to "prove that we’re the account holder."?!
When sending request {{url}}/futures/data/topLongShortPositionRatio?symbol=BTCUSDT
I am getting the following error
"error": "Not Found",
"message": "No message available",
"path": "/futures/data/topLongShortPositionRatio"
Would be nice to have so one could generate clients with: https://github.com/OpenAPITools/openapi-generator
Consider verifying the swagger.json with: https://editor.swagger.io/
I'm getting Error while importing: format not recognized
Postman version: v7.23.0
Any idea?
Hi!
I'm trying to test the binance Futures API but I always get:
{
"code": -1022,
"msg": "Signature for this request is not valid."
}
I have this restrictions for the API
I have the correct API key and Secret key on my postman environment, but I'm getting the error with all requests which the signature is required.
What I'm doing wrong?
Thanks in advance.
Hey, I am looking for an API scheme for strategy orders in Binance (OCO, OTOCO). Unfortunately nor API docs nor this repo does not contain such information. Is it possible to add it?
Hi,
When I try to create new order from Postman I got "-1022 Signature for this request is not valid." error. I checked the address for the error but it seems there is no problem about my post. My raw URL is below, changed my secret with XXXX
help please.
Replace "REGULAR" in "/sapi/v1/lending/project/list?asset=USDT&type=REGULAR..." to "ACTIVITY, since it no longer exists.
Hello, sorry for opening this issue, but i'm really confused, is there any option to do this through "New Order" (Trade)
Because if you opening position by MARKET , you need to enter price or qtty of coin, but i need to enter the qtty of my USDT balance =(
I'm executing the following endpoint: /sapi/v1/capital/deposit/hisrec?coin=BTC&status&startTime&endTime&addressTag=×tamp={{timestamp}}
in Postman and i get "401 Unauthorized" with the message "You are not authorized to execute this request".
I can make others queries so the parameters seems to be right.
Any help?
Hi I'm not sure if this is intended and I'm in the wrong here but it looks like the request urls seem to be outdated using /v1/ rather than /v3/ and I assume v1 is depreciated because I was never able to get it to work.
Also different collections of requests seem to have a d, s or f in front of api leading to things like /dapi/, /sapi/, /fapi/ none of which work, at least for me.
If this is intended for some reason then please ignore but I figured I would bring it to your attention,
Change Log 2021-11-19
GET {{url}}/sapi/v1/pay/transactions?timestamp={{timestamp}}&signature={{signature}}
Not Found Fields: [
Pay ID ?
recipient ?
sender ?
orderId ?
note ?
]
Example Response:
{
"code": "000000",
"message": "success",
"data": [
{
"orderType": "C2C",
"transactionId": "C_P_XXXXX",
"transactionTime": 1633941540055,
"amount": "236.6",
"currency": "USDT",
"fundsDetail": [
{
"currency": "USDT",
"amount": "236.6"
}
]
}
],
"success": true
}
how to create signature?
This link is break in the README.md:
https://academy.binance.com/economics/binance-api-series-pt-1-spot-trading-with-postman
Hello, I'm using non-standart language and communicate with HTTP by plain headers. I'm wanted to get some futures methods info (for example positionRisk
) via sockets, but gets an empty answer even my balance is changing (I have some futures open orders). I'm sending the following headers to the server:
GET /ws/L7Awe0UboTNATaoiutuz9lSZg6wRYO1A1PquzoS4SjIg8Cq2lRsabadIQcYlFWI9 HTTP/1.1\r\n
Host: stream.binance.com\r\n
Accept: */*\r\n
Connection: Upgrade\r\n
Upgrade: WebSocket\r\n
Pragma: no-cache\r\n
Sec-WebSocket-Version: 13\r\n
Sec-WebSocket-Key: 6DLUcxfnOxFAet7PJDrXYg==\r\n
\r\n
\r\n
And getting the correct answer headers, but answer body is empty.
HTTP/1.1 101 Switching Protocols
Date: Fri, 28 May 2021 14:26:44 GMT
Connection: upgrade
Upgrade: websocket
Sec-WebSocket-Accept: KFe2yYd1Hu9qNmIaaZR56apFrCQ=
I'm tried both of the endpoints to generate listen key (fapi/v1/listenKey
and api/v3/userDataStream
) and with testnet too with no luck.
What it can be, because, for example, pairs trade info (/stream?streams=btcusdt@kline_1m
) working good?
Thanks.
I couldn't find any market based orders endpoints... closest i could think is below
{{url}}/api/v3/order?symbol=BTCBUSD&side=BUY&type=MARKET&timeInForce=GTC&quantity=0.00020&price=1×tamp={{timestamp}}&signature={{signature}}
but when i run it i get below
{
"code": -1022,
"msg": "Signature for this request is not valid."
}
so what am i missing ???
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.