Ethereum -API call list: test data training
======================================================== ================ === == ==
As a beginner, it is great that they strive to explore the Ethereum -API. Here you will find an article on how to restore the order data using Python and Binance -API.
preliminary conditions
Before we immerse yourself in the code, make sure you:
- An api bony account (create one at [binance.com/api alan (
- Python-Binance ‘library installed (
PIP Installation Python-Binance
)
- Basic knowledge of Python and API calls
Restoration of order data with Python
We will use the “Binance Futures” class in the “Python Binance” library to access the order data. Here is the code:
`Python
Import JSON
From the date of the import of data
#Set -set -Set the API -Binance registration information
api_key = "your_api_key"
api_secret = "your_pi_secret"
Set the last point of the API and the reason -
Base_url = " api/v3/futures"
Endpoint = "/Open"
Set your command symbol (e.g. ETH/USDT)
Symbol = "et/usdt"
DEF GET_OPEN_OFERS (API_KEY, API_SECRET):
Create an API Binance object with your login information.
CUSTOMER = Binance.Client (api_key = api_key, api_secret = api_secret)
Restore open commands for the specified symbol
Answer = customer.futures.Getspendler (endpoint = endpoint, symbol = symbol)
Data = json.loads (answer. body)
Only return the required command data (symbol, price, origin, site)
Return [data ["contract"] ["" symbol "], data [" open "], data [" originty "], data [" site "]]]]
Restore and print out your order data for ETH/USDT
commands = get_open_orders (api_key, api_secret)
For symbol, price, original, _ in commands:
print (f "symbol: {symbol}, price: {price: .4f}, originty: {origin}")
Explanation
- We create an API Binance object with your login information.
- We have set the final and fundamental URL for our API request (e.g. api/v3/futures
).
- We indicate the order symbol (et/USD in this example).
- We have restored open commands with the method of the motto.
- We analyze the JSON response data and only return the required command data (symbol, price, origin, location).
Example of the use of cases
- Monitoring of order activity for a certain couple
- Analysis of market trends by taking over historical data
- Create commercial or automation bits using open commands as a trigger
Remember to replace your_pi_key
and your_pi_secret` with your API -Binance registration information. Also note the limits of the API Binance rate and adjust the code.
I hope this will help you to adopt control data from Ethereum -API!