Hello, I’m testing the Binance API for corporate trading using the testnet. Whatever I do I keep getting timestamp errors, but when checking my timestamp and Binance server the difference is small.
BASE_URL = 'https://testnet.binance.vision/api
headers = {
'X-MBX-APIKEY': API_KEY
}
PATH = '/v3/account'
timestamp = int(time.time() * 1000)
params = {
'recvWindow': 5000,
"timestamp": timestamp
}
query_string = urlencode(params)
params['signature'] = hmac.new(SECRET_KEY.encode('utf-8'), query_string.encode('utf-8'), hashlib.sha256).hexdigest()
url = urljoin(BASE_URL, PATH)
r = requests.get(url, headers=headers, params=params)
When running the below code to check timestamp difference I usually get around 300
url = "https://testnet.binance.vision/api/v1/time"
t = (time.time()*1000)
r = requests.get(url)
result = json.loads(r.content)
print(int(t)-result["serverTime"])
Any suggestions is appreciated!