I’m trying to implement a getQuotes method and then a convert from one asset to another but I am getting an unauthorised response.
I’ve checked my API key and I’ve got read and Spot/Margin trading enabled so I can’t work out what’s going on.
My python code snippet is
timestamp = int(time.time() * 1000)
query_string = f'fromAsset={from_asset}&toAsset={to_asset}&toAmount={amount}&recvWindow=5000×tamp={timestamp}'
signature = generate_signature(query_string, secret_key)
url = f'{base_url}/sapi/v1/convert/getQuote'
headers = {
'X-MBX-APIKEY': api_key,
}
data = {
'fromAsset': from_asset,
'toAsset': to_asset,
'toAmount': amount,
'recvWindow': 5000,
'timestamp': timestamp,
'signature': signature
}
response = requests.post(url, headers=headers, params=data) # Corrected from data=data to params=data
I’ve tried to find the relevant information in Binance docs but it’s not coming up with why it wouldn’t work without reading and spot/margin enabled.
I’m based in Australia but I’m able to please market and limit orders and also convert via Binance website.