** Recovering the Data in real time
In this article, we will tell you to recover the Data in real time for a symbols from the Binance the Binance the Binance-Connecton bookshop
Prerequisites
- Install the requisted bookstores:
PIP install Binance-Connector-Python
- Create an API Binance account and get the API key
- Download theBinance-Connector-Python ‘library
Step 1: authenticate with bees binance
Before recovering the Data, it is necessary to authenticate with the bees the bees. You can do it by creaty an object confident:
Python
import binance.connector as BC
Class configuration:
Binance_api_key = 'Your_bance_api_key'
Binance_api_secret =
Your_banse_api_key
Replac
is your toy_pi_api_secret
client ', it is used to the interact whe binance bees:
Step 2: Create a standing object
Create an object
`
Python
Client = bc.client (api_key = config.binance_api_key,
Api_secret = config.binance_api_secret)
Step 3: Recover the Data in real time for symbols
To recover the Data in real time for a set of synbools, use Symbol 'parameter in the query. You can pass a matrix of Simbols to obtain for multi-mult couples:
Python
Couples = ['Btcusdt', 'Ethusdt']
List of Simbols
Client.symbol (symbol = 'btcusdt')
symbol 'paramter with the optation' time
This is the latt information on BTC/USD and Eth/USD.
Step 4: Get in real time for each symbol
To obsin data in real time for symbol, use the
'true
. This is the discet brand of this current date:
`
Python
Client.Symbol (symbol = 'BTCusdt', Time = True)
This is the current of this year, the volme and the market data.
Example code
Here is a snippt of example code that show to how to recover
`Python
import binance.connector as BC
Realtimetted class:
Def __init __ (self):
Self.config = config ()
self.client = bc.client (api_key = self.config.opi_api_key,
Api_secret = self.config.binance_api_secret)
Def Get_real_Time_data (self, Symbol = none, time = false):
If not a symbol and time:
return {
'symbol': '',
'Time': True
}
If not a symbol:
Increase Valuerror ("the Simbol is required")
Couples = [symbol]
For couple in pairs:
Data = self.client.symbol (symbol = couple)
If time:
Return {'Data': Data, 'TimesTamp': Data ['TimesTamp']}}}
other:
Return {
data, {'Data': ne}}
If __name__== '__main__':
Retriever = Realtimetariever ()
For symbol in ['btcusdt', 'etthusdt']:
Print (retriever.get_real_time_data (symbol = symbol))
“
This code snipper is a recover real-time for real data useBinance-Connector-Pitithon. You can add multiple symbols by adding thee and modify the loop.
Conclusion*
In this article, we have been translated the postations of the recovery of Data in real time the Binance Using “Binance-Connector-Python” Following the passages and examples, you chauld to a recover the latest information on the multiple binance eachy 15 seconds. Remember to replace the Bees and the following whe acting walues and always on the best practices xternal bees.