What is the base url for the margin testnet?
The following code 404s when using a margin endpoint but is fine when I use the spot api.
testnet_base = "https://testnet.binance.vision"
def timestamp():
return round(time() * 1000)
"""USE ORDERED DICT FOR PARAMS"""
def make_url(url_base, api_path, params=None):
if params is None:
params = OrderedDict()
params["timestamp"] = timestamp()
query_string = urlencode(params)
signature = hmac.new(secret_key, query_string.encode(), hashlib.sha256).hexdigest()
return f"{url_base}{api_path}?{query_string}&signature={signature}"
def get_account_data():
url = make_url(testnet_base, "/api/v3/account")
req = requests.get(url, headers={"X-MBX-APIKEY": api_key})
return json.loads(req.text)
pprint(get_account_data()) # this is fine
req = requests.get(make_url(testnet_base, "/sapi/v1/margin/pair"), headers={"X-MBX-APIKEY": api_key})
print(req.status_code) # 404
print(req.text) # ''