binance-us / binance-us-api-docs

Official Documentation for the Binance US APIs and Streams
407 stars 170 forks source link

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

Open RRainbowCodeRR opened 2 years ago

RRainbowCodeRR commented 2 years ago

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."}

PengRusty commented 1 year ago

Can you please check if you are using IPv6 address?