Binance API: symbol price ticker. What delimiter for several symbols?

Viewed 3605

Binance provides good API documentation but in some cases, it looks either incomplete or unclear at least. Symbol Price Ticker: https://binance-docs.github.io/apidocs/spot/en/#symbol-price-ticker

Question: is there a way to get prices just for several symbols (more than one but not a complete list)? It looks illogical but seems Binance handles either a single symbol or an entire list at once. Attempts to use different delimiter (like: ",", ";", "+", "|", etc) leads to an error:

request: api/v3/ticker/price?symbol=DOGEUSDT,ETHBTC

response: Illegal characters found in parameter 'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'

As a result, integration code is not optimal - developers have to send several similar requests or extract required data from hundreds of items.

3 Answers

You're correct, there is no way to select just a set of symbols. If you want one request then you need to fetch all.

Binance has updated the /api/v3/exchangeInfo endpoint recently to take a list of symbols in this format ["DOGEUSDT","ETHBTC"], so maybe they will add that to other endpoints.

Same problem here. I've changed my timer from grabbing every 1 second to every 5 seconds, sending 5 requests in a for loop. It's annoying and unnecessary to create multiple objects for the same data:

QString symbols[5] = { "BTCUSDT", "BNBUSDT", ... etc };

for(auto symbol : symbols){
    GetData(symbol);
}

The QString is of course from QT. Without it, you can use std::string.

Related