Implementation of binance API data in real time with python
In this article, we will review how to load real -time data for a Binance symbol set.
* prewites
- Install the desired libraries: Baking Mining-Contector-Connewor
- Create an API Binance API account and obsession with the API key
- Download the library
Step 1: Authlonticate Wiel with API *
Before loading the data, you need Touthenticate Binance Anp using the API key. You can do this by creating an object 1config ‘:
`Comfort
Emport binance.contector by BC
Class configuration:
Binance_pi_key = ‘your_binance_pi_cey '
Binance_pi_ci_ci_ci_ci_ci_ci_ci_pi_i_i_i_i_i_ci_ci_ci_ci_ci_ci_ci_ci_ci_cet '
P
Replace the symptoms of your_binance_pi_ci_key and anour_binance_api_ipi_i_i_i_i_i_i_ci_ci_ci_cet your API key and secret.
Step 2: CIATE AND CLIENT ORJECT
Create a steel object that is using the Binance API interaction:
`Comfort
You have a client = b.client (ap_eye = config.binance_ci_Key,
AP_SECRET = config.binance_pi_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_ci_c_cet)
P
Step 3: Load real -time data for symbols
To get a set of real -time data for a set of symbols, using Quey in your Quey. You supal a variety of symbols to get more pages:
`Comfort
pars = [“btcuscdt”, “like this”
list of symbols
Climate.Symbol (Anscusct symbol)
P
This will return the latest information about both BTC/UUS/US/USD.
Step 4: Get real -time data for each symbol
Go in real time for each symbols using the “symbol” parameter with the option to “TRUE”. Is a sophisticated dictionary with the appropriate market:
`Comfort
Climate.Syboll (symbol of AnscuscCCCCT ', Time = TRUE)
P
This will return kuna price, volume and other data market.
Impl Code
Shere is a Snipt Snipt test to get real -time WinTa data for multiple symbols that are used for multiple symbols of symbols.
`Comfort
Emport binance.contector by BC
Class Realtimedatatorereter:
Def ______ (yourself):
self.configu ()
me
AP_SERET = self.
Denf is gef_real_time_data (self, symbol = none, time = false):
If the note and myme:
reform {
''.
“Time”: Try
}
IIF not:
Valueerror (“Smbol is required”)
pars = [symbol]
for the patient in the patient:
data = self.clin.
Time:
Reputation {'teet: Date, "Timestamp": Date [timestamp "]
otherwise:
RETURN {
DAT, August: none}}
IIF _name__ =.
to load = realtimedaterever ()
For the symbol in [BTCUDT "," like this "]:
Print (retever.get_real_data (symbol = symbol)
P
The Snippetitites code demonstrates the real-time date for multiple symbols Sing Sing Sing Draft-Connew-Connew. You can add arrent by connecting the list and adjust the loop.
* Conclusion
In this art, we dealt with the basics of real -time data loads that break the Linance API, which uses binance. Subsequent steps and tests will be able to load the latest information about multiple binanka 15 seconds. Be sure to place your key and secret with the Witt Witt and the letters of monitoring practicing security and alleviation that limit the external API.
Add comment