19

I would like to get only one pair from the response. And I can't really understand how I should pass my parameter.

Instructions say:

Symbol price ticker
GET /api/v3/ticker/price
Latest price for a symbol or symbols.
Weight: 1 for a single symbol; 2 when the symbol parameter is omitted
Parameters:
Name Type Mandatory Description symbol STRING NO -
If the symbol is not sent, prices for all symbols will be returned in an array."

I'm able to get all symbols in the response body, but can't get a single one. I have already tried (in Postman) these endpoints:

  1. https://api.binance.com/api/v3/ticker/price/btcusdt
  2. https://api.binance.com/api/v3/ticker/price/symbol=btcusdt
  3. https://api.binance.com/api/v3/ticker/price/?symbol=btcusdt

Here is the link to entire API: https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#24hr-ticker-price-change-statistics

So, which endpoint is correct?

postman result

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
programmer123456
  • 201
  • 1
  • 2
  • 4
  • 1
    Check here `https://api.binance.com/api/v3/ticker/price` to see what acceptable symbols you can choose from. Then you use this `https://api.binance.com/api/v1/ticker/price?symbol=LTCBTC` to, for example, get the single pair for LTCBTC. Let me know if this answers your question, or if you need more clarification. – geekTechnique Jan 24 '21 at 01:57
  • 1
    Yes, now I see my mistakes. Redundant slash ('/') after "price" and lowerCase symbol. Thank You for Your answer. – programmer123456 Jan 26 '21 at 14:51

4 Answers4

34
  1. https://api.binance.com/api/v3/ticker/price/?symbol=btcusdt

You must use Query without /

and Binance's /api/v3/ticker/price endpoint need symbol query as Upper case.

so you must request as below

https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT

reaver lover
  • 624
  • 7
  • 20
9

You can you this API link to get all pairs only current price and symbols:

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

This for specific symbol and price:

https://www.binance.com/api/v3/ticker/price?symbol=BNBBTC

This for all pairs with full info:

https://api.binance.com/api/v3/exchangeInfo

This for 1 pair full info:

https://api.binance.com/api/v3/exchangeInfo?symbol=BNBBTC

Here is Binance API Detail pages:

https://binance-docs.github.io/apidocs/spot/en

https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md

Humayun MHA
  • 363
  • 3
  • 6
2

Is there a chance to send more queries at once like for example BTCUSDT and ETHUSDT ?

When I am trying various combinations I get a reply of:

{"code":-1104,"msg":"Not all sent parameters were read; read '1' parameter(s) but was sent '2'."}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 2
    If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/31668339) – Emil Sierżęga May 05 '22 at 09:52
  • 4
    `?symbols=["BNBBTC","ETHUSDT"]` – tony gil Jun 03 '22 at 18:31
1

Yes you can send multiple symbols but you have to loop

for (const symbol of symbols) {
const query_String = await queryString({ symbol });
 await axios({
  method: "GET",
  url: `${Settings.Endpoint}/v3/ticker/price?${query_String}`,
})

}