Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Binance API, simple GET price by ticker

Tags:

java

api

binance

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

like image 398
Bartosz Maleta Avatar asked Jan 23 '21 21:01

Bartosz Maleta


People also ask

What can I do with Binance API?

It allows you to easily buy, sell, trade, and swap cryptocurrency. Python-binance is an application programming interface that allows you to connect to the Binance servers via the Python programming language. With the API, you can make orders, trade, withdraw and get real-time data from the Binance exchange.

Is it free to use Binance API?

Binance APIBinance is a free to use API that uses third-party platforms to allow users to access and trade on crypto currency markets. Binance, when you consider the sheer number of crypto currency trades, is one of the largest single market players out there.


3 Answers

  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

like image 188
reaver lover Avatar answered Oct 19 '22 19:10

reaver lover


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

like image 42
Humayun MHA Avatar answered Oct 19 '22 20:10

Humayun MHA


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'."}
like image 1
linux_beginner Avatar answered Oct 19 '22 21:10

linux_beginner