Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Binance API. Duplicate values for parameter 'symbols'

Can’t get prices for multiple symbols, gives error {'code': -1101, 'msg': "Duplicate values for parameter 'symbols'."}. I do as indicated in the documentation GitHub

This is a my code

import requests

symbols = ["KEYUSDT","BNBUSDT","ADAUSDT"]

url = 'https://api.binance.com/api/v3/ticker/price'
params = {'symbols': symbols}

ticker = requests.get(url, params=params).json()
print(ticker)

What am I doing wrong?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to specify the list as a string:

import requests

symbols = '["KEYUSDT","BNBUSDT","ADAUSDT"]'

url = 'https://api.binance.com/api/v3/ticker/price'
params = {'symbols': symbols}

ticker = requests.get(url, params=params).json()
print(ticker)

Result:

[{'symbol': 'BNBUSDT', 'price': '317.50000000'}, {'symbol': 'ADAUSDT', 'price': '0.56690000'}, {'symbol': 'KEYUSDT', 'price': '0.00504000'}]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading