Avançar para o conteúdo
Início » Blogue » Ethereum: How can I get only the figure of a symbol in Binance API using Python

Ethereum: How can I get only the figure of a symbol in Binance API using Python

I can send you like just a Figure Symbol in Binance Api with Python. Tems are not lesser, it is extent to the fact that the binance api will find authentification for access to the data in the reality, and some functions may be changed.

Here’s the primer of a code fragment that uses the Library “Putting” with a data json to get the last shadow for the concrete symbol (in the tribute, ETH) from the API Binance:

`Piton

Importies

JSON IMport

Def Get_eth_price (Simvol):

Ethereum: How can I get only the figure of a symbol in Binance API using Python

Install your ucere binance api and token

API_KEY = 'Your_API_KY'

Secret = 'Your_secret_key'

Build URL -Address of the API API API

URL = f'https: //api.binance.com/api/v3/Ticker/price?

Ask:

Ottuzta requested in API

Response = Reques.get (URL, Headers = {'X-API KEY': API_KEY})

Pierce, li invisible

If Response.Status_code == 200:

Discharge of data json from the answer

Data = Json.loads (Response.Text)

Return the last shadow for the concrete symbol

Data Vozurat ['Channa']

Still:

PRINT (F "Failed to Take a Shadow for {Symbol}. Code: {Response.status_code}")

Return no

Crowfs.

Pack (F "Passed Lying: {E}")

Return no

Primmer Using:

If __name__ == "__main__":

Symbol = 'eth'

change on a stroke symbol (for example, ETH, BTC, etc.)

Channe = Get_eth_price (Simvol)

If the shada no:

PRINT (F "The last shadow for {Symbol} is: {Trus}")

Important receipts:

1.

  • API key: Zagolovok X-API KEY-IS APPLIED FOR AUTENTIFICATION PRESS. Receive what you are putting on how to get a binance access token for this whole.

3.

Code of Enlightenment:

  • Функция get_eth_price принимает символ в качестве ввода и конструирует URL -адрес конечной точки API с использованием параметровsymbol, tokensymbol 'и “ Параметры.

  • He drops the invited GET in API with the set up URL.

  • If you are invited, he analyzed the data from the answer and the afternoon shadow for the concrete symbol.

  • Function also reveals any exceptions, which can be spread out.

Remember: always check your docking Binance API on the subject naiblya’s financial information about the symbols of avialy, interstites and techniques of authentification.

Ethereum Clones There Duplicate

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *