2

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?

hexelot
  • 31
  • 5

1 Answers1

2

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'}]
Cow
  • 2,543
  • 4
  • 13
  • 25