https://api.binance.com/api/v3/ticker/price

https://api.binance.com/api/v3/ticker/price

Hi there

When using the api/v3ticker/price end point I get a 404 error response.
When I use the api/v3/order end point in the same session it works fine.

Below is the python code for the /ticker/price

PATH = ‘/api/v3/ticker/price’
BASE_URL = ‘https://api.binance.com
timestamp = int(time.time() * 1000)
params = {
‘symbol’: ‘BTCUSDT’
}
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.post(url, headers=headers, params=params)
print(r.url)
print(r.status_code)
if r.status_code == 200:
data = r.json()
print(json.dumps(data, indent=2))
else:
raise BinanceException(status_code=r.status_code, data=r.json())

Below is the python code for the /order

PATH = ‘api/v3/order’
BASE_URL = ‘https://api.binance.com
timestamp = int(time.time() * 1000)
params = {
‘symbol’: ‘BTCUSDC’,
‘side’: ‘BUY’,
‘type’: ‘LIMIT’,
‘timeInForce’: ‘GTC’, # Good till Cancelled
‘quantity’: 0.01,
‘price’: 45000.0,
‘recvWindow’: 5000, #specifies the number of milliseconds after timestamp the request is valid for
‘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.post(url, headers=headers, params=params)
print(r.url)
print(r.status_code)
if r.status_code == 200:
data = r.json()
print(json.dumps(data, indent=2))
else:
raise BinanceException(status_code=r.status_code, data=r.json())

I would be very grateful if you could provide any help.

Thanks in advance.

Glyn.

r = requests.post(url, headers=headers, params=params)

The price ticker endpoint requires a GET https request, while you are sending a POST https request

@tantialex would you help me with a similar challenge? Please take a look at it: Binance Symbol Price Ticker USDCCOP not working

Hi there

Thanks very much for your answer.
Sorry to bother you with something so simple.
I couldn’t see the wood for the trees.
Thanks again.
Cheers
Glyn