· 8 years ago · Feb 02, 2018, 11:50 PM
1SIGNED endpoints require an additional parameter, signature, to be sent in the query string or request body.
2Endpoints use HMAC SHA256 signatures. The HMAC SHA256 signature is a keyed HMAC SHA256 operation. Use your secretKey as the key and totalParams as the value for the HMAC operation.
3The signature is not case sensitive.
4totalParams is defined as the query string concatenated with the request body.
5
6import requests, json, time, hashlib
7
8
9apikey = "myactualapikey"
10secret = "myrealsecret"
11test = requests.get("https://api.binance.com/api/v1/ping")
12servertime = requests.get("https://api.binance.com/api/v1/time")
13
14servertimeobject = json.loads(servertime.text)
15servertimeint = servertimeobject['serverTime']
16
17hashedsig = hashlib.sha256(secret)
18
19userdata = requests.get("https://api.binance.com/api/v3/account",
20 params = {
21 "signature" : hashedsig,
22 "timestamp" : servertimeint,
23 },
24 headers = {
25 "X-MBX-APIKEY" : apikey,
26 }
27)
28print(userdata)
29
30{"code":-1100,"msg":"Illegal characters found in parameter 'signature'; legal range is '^[A-Fa-f0-9]{64}$'."}