- How to Get Binance Market Prices and Other Data
- All Binance Markets in One Listing
- Binance Market Data
- Market Current Price
- Best Ask Price
- Best Bid Price
- Last Trade Price
- 24h Price Change
- Open Price
- 24h Highest Price
- 24h Lowest Price
- Close Price
- Market Volume
- Market Base Volume
- Binance Historical Data
- Historical Price
- Historical Open Price
- Historical High Price
- Historical Low Price
- Historical Close Price
- Historical Market Volume
- Historical Market Base Volume
- tanaikech / submit.md
- This comment has been minimized.
- NDNewell commented Jun 17, 2019
- This comment has been minimized.
- tanaikech commented Jun 18, 2019
- This comment has been minimized.
- Anastasgrek commented Aug 8, 2020
- This comment has been minimized.
- asterix1967-github commented Nov 19, 2020
- This comment has been minimized.
- htadashi commented Jan 31, 2021
- Binance API To Google Sheets: Binance API Example [Tutorial]
- How to connect Binance to Google Sheets
- Step 1.) Install and open the Apipheny Add-on in Google Sheets
- Step 2.) Choose a Binance API URL endpoint
- Step 3.) Enter your Binance API URL into the apipheny Add-on
- a.) For Public Endpoints
- b.) For Authenticated Endpoints
- Step 4.) Add your Binance API URL into the Apipheny add-on
- Step 5.) Run the Binance API Request
How to Get Binance Market Prices and Other Data
All Binance Markets in One Listing
This function call will return the list of all markets along with all their data point. It is recommended to use this to avoid the Google Sheets imposed API call quota.
The following market data will be returned:
- last_updated , when the data has been fetched from the exchange, timezone is UTC time.
- market , the market name following the syntax BASE/QUOTE .
- price , the current price, either the last trade price when available or the current ask price.
- ask , the best ask price currently in the order book.
- bid , the best bid price currently in the other book.
- open , the 24h open price.
- high , the 24h high price.
- low , the 24h low price.
- close , the 24h close price, often the same as the last price.
- last , the price of the last trade.
- change 24h , the price change in percentage over the last 24h.
- volume , the volume traded over the last 24h in quote currency ( USD in BTC/USD ).
- volume_base , the volume traded over the last 24h in base currency ( BTC in BTC/USD ).
Notes:
- When the exchange doesn’t provide a given market data, a hyphen (-) will be shown.
- Binance doesn’t have USD markets. Due to a large number of users getting Market not available error, any query for a Binance pair with a USD quote will be transparently mapped to USDT.
Binance Market Data
Market Current Price
This will return Ethereum price in Bitcoin as currently traded on Binance:
Same thing as calling =CRYPTOFINANCE(«BINANCE:ETH/BTC», «price») .
Best Ask Price
This will return Ethereum best ask price in Bitcoin as currently available on Binance order book:
Best Bid Price
This will return Ethereum best bid price in Bitcoin as currently available on Binance order book:
Last Trade Price
This call will return Ethereum last trade price in Bitcoin as it just happened on Binance:
24h Price Change
This call will return Ethereum price change percentage in Bitcoin over the last 24h on Binance:
Open Price
This call will return Ethereum open price in Bitcoin as of 24h ago on Binance:
24h Highest Price
This call will return Ethereum highest price in Bitcoin over the last 24h ago on Binance:
24h Lowest Price
This call will return Ethereum lowest price in Bitcoin over the last 24h ago on Binance:
Close Price
This call will return Ethereum last trade price in Bitcoin as it just happened on Binance:
Same thing as calling =CRYPTOFINANCE(«BINANCE:ETH/BTC», «last») .
Market Volume
This call will return Ethereum traded volume in Bitcoin over the last 24h on Binance:
Market Base Volume
This call will return Ethereum traded volume in ETH over the last 24h on Binance:
Binance Historical Data
Historical prices are available on daily and hourly candles, including open , high , low , close , volume and volume_base .
Quota: Historical data has with a quota of 25 calls per day per user. The quota reset itself everyday at midnight UTC. For unlimited data and full historical listing the Historical Data subscription is available.
ProTip: See here for how to reference other cells to build the date or specifying the hour.
Historical Price
Same thing as calling close .
Historical Open Price
Historical High Price
Historical Low Price
Historical Close Price
Historical Market Volume
Historical Market Base Volume
CRYPTOFINANCE (Google Sheets add-on) and its authors are not responsible for any trading or financial loss incurred by following the data returned. The service is provided «as is», without any warranty of any kind, expressed or implied.
Источник
tanaikech / submit.md
Binance API for Google Apps Script
This sample script is for using Binance API by Google Apps Script. This script encryptes «signature» like samples. In this script, «Example 1: As a query string» is used, and it retrieves «All orders (SIGNED)» by «GET».
This comment has been minimized.
Copy link Quote reply
NDNewell commented Jun 17, 2019
This comment has been minimized.
Copy link Quote reply
tanaikech commented Jun 18, 2019
Welcome. Thank you, too.
This comment has been minimized.
Copy link Quote reply
Anastasgrek commented Aug 8, 2020
I got this error! What can I do?
This comment has been minimized.
Copy link Quote reply
asterix1967-github commented Nov 19, 2020
Dear,
could you help me ? , Please !
Few days , I try to run with this Binance API
do you have a idea? it’s about Query String and Body query , but really I don’t find a solution
It will be great if I can receive a help ! Thanks !
I will have always this return from API
This comment has been minimized.
Copy link Quote reply
htadashi commented Jan 31, 2021
@Anastasgrek and @asterix1967-github
I believe this happens because GoogleAppsScript automatically sets up the X-Forwarded-For header when these functions are ran. This may be activating a Cloudflare protection which blocks the request.
You could try to use @tanaikech sensei workaround here, but please note that a wrong setup of the webapp could let others run these functions without your permission.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
Binance API To Google Sheets: Binance API Example [Tutorial]
👉 Looking for a cryptocurrency portfolio tracker? Click here to learn more about CoinStats, a crypto portfolio manager that you can use to track your holdings from multiple wallets and exchanges.
How to connect Binance to Google Sheets
Binance is one of the world’s most popular cryptocurrency exchanges, and their API is one of the most popular crypto exchange APIs. If you haven’t signed up for Binance yet, click here to sign up and register a new account.
We can use Binance’s API to import data from Binance into Google Sheets. In this tutorial, you’ll learn how to connect the Binance REST API to Google Sheets in 5 steps using the Apipheny API integrator for Google Sheets:
- Install the Apipheny Add-on
- Choose your Binance API endpoint
- Enter your Binance API request into Apipheny
Step 1.) Install and open the Apipheny Add-on in Google Sheets
To pull data from the Binance API to Google Sheets, first install and open the Apipheny Google Sheets add-on.
Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more.
1.) Install Apipheny by clicking the Install button on this page.
2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons option in the top menu. In the add-ons menu, you should see Apipheny.
Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.
Step 2.) Choose a Binance API URL endpoint
An “endpoint” is a specific API URL that returns the specific data you want from Binance. In this section we show you how to browse the Binance API documentation to find the URL that returns the specific data you need. If you’d like to see specific examples of URLs you can use, just skip to the next section.
To explore endpoint URLs and query requirements, go the Binance API documentation page here: https://binance-docs.github.io/apidocs/spot/en/#general-info
All Binance endpoint URLs are created by appending an endpoint-specific path to the root URL:
If you are experiencing problems with the above API root, please use an alternate as outlined in the general API information section of the official Binance documentation.
For this example, we are using the API URL:
If you want to use the same example URL as us, skip to the next section. If you want to create your own endpoint URL, keep reading to learn how.
To research the different endpoint URLs you can use, visit the documentation here: https://binance-docs.github.io/apidocs/spot/en/#general-info
For GET endpoints, parameters must be sent as a query string, while for POST, PUT, and DELETE endpoints, they may be sent either as a query string, or in the request body, with content type application/x-www-form-urlencoded. No specific order is imposed on the parameters and both the query string and the request body approach can be used for the same query.
If your API endpoint needs to use an API key, then it must be sent through a dedicated X-MBX-APIKEY header, as seen here:
Signed endpoints
“Signed” Binance API endpoints that require HMAC SHA256 will not currently work with our add-on, but endpoints that do not require HMAC SHA256 will work, such as the /allPairs endpoint we covered above. Some Binance API endpoints require HMAC SHA256 and others don’t. This tutorial goes through an example that doesn’t require HMAC SHA256.
The reason signed endpoints don’t currently work with our app is because they require an additional parameter called signature, a keyed HMAC SHA256 signature with your secretKey as the key, and a concatenation of all the query’s parameters as the value passed to the HMAC operation. Signed endpoints also require a timeStamp parameter, populated with the request’s millisecond timestamp:
An example of a signed endpoint is the Order API endpoint:
You can tell if an endpoint is signed or not because when you look at the documentation for that endpoint, it will say “(HMAC SHA256)” next to the URL.
Step 3.) Enter your Binance API URL into the apipheny Add-on
a.) For Public Endpoints
Public endpoints can be accessed without an API key.
To identify the public endpoints you have to look for those which don’t require an API key or a signature in their documentation. We are interested in the ones that have “NONE” as “security type” in the table below:
Security Type | Description |
NONE | Endpoint can be accessed freely. |
TRADE | Endpoint requires sending a valid API-Key and signature. |
MARGIN | Endpoint requires sending a valid API-Key and signature. |
USER_DATA | Endpoint requires sending a valid API-Key and signature. |
USER_STREAM | Endpoint requires sending a valid API-Key. |
MARKET_DATA | Endpoint requires sending a valid API-Key. |
Security type table
The security type for each endpoint can be found next to its title, inside round brackets “( )”.
If an endpoint doesn’t have round brackets next to its title and doesn’t have a HMAC SHA256 reference, it means that its security type is NONE and is a public endpoint that can be accessed without an API key or a signature.
The only category from the Binance API documentation that contains public endpoints, that requires no API key is Market Data Endpoints .
An example public endpoint that requires no key is Symbol Price Ticker, which gets the latest price for one or multiple symbols. It uses the GET method and the URL for this endpoint is:
To use this endpoint, just copy and paste this URL into the Apipheny add-on. After you enter the URL into the add-on, click the “Run” button at the bottom of the Apipheny add-on and each crypto’s current price will be imported into your Google Sheet, as shown in the screenshot:
MORE EXAMPLE BINANCE API URLS
– Check Server Time, which tests connectivity to the Rest API and gets the current server time. It uses the GET method and its URL is https://api.binance.com/api/v3/time
To use this endpoint, just copy and paste this URL into Apipheny. After you enter the URL into the add-on, click the “Run” button at the bottom of the Apipheny add-on and the data will be imported into your Sheet, as shown in this screenshot:
– Order Book, which provides a listing of the ongoing orders in the system. It uses the GET method and its URL is https://api.binance.com/api/v3/depth?symbol=
When using this endpoint, do not forget to replace with an actual symbol. I choose BTCUSDT value for this example.
– Symbol Order Book Ticker, which gets the latest orders for one or multiple symbols. It uses the GET method and its URL is https://api.binance.com/api/v3/ticker/bookTicker
– Recent Trades List, which returns a list of most recent trades on the platform. It uses the GET method and its URL is https://api.binance.com/api/v3/trades?symbol=
Do not forget to replace with an actual symbol. I choose ETHBTC value for this example:
b.) For Authenticated Endpoints
In order to access most Binance REST API endpoints, you will need an API key. To obtain an API key, follow the instructions below. If you already have your key you can skip this section.
1. After logging in to your Binance account, click API Management in the user center drop-down box:
2. If you did not install 2-factor authentication (2FA) when creating your Binance account, you will be asked to do add 2FA at this point:
In this example I chose SMS Authentication. Click the Send SMS button to receive a code on your mobile phone. After you have received the code, enter it in the SMS Verification Code section. You can also choose Google Authentication, which is more secure. After you add 2FA, this popup will disappear and you can continue obtaining your API key.
3. When the API management page finally opens, enter a name (label) for your private API key, and then click the Create button:
4. Next, fill in the Google Authentication Code or SMS Authentication Code again, to confirm the API Key creation for your account:
5. Once you have passed the 2FA Authentication, the system will send a confirmation email to the email address of your Binance account. You can go directly to your email or click the Go to email and verify button on the Binance page:
6. In the email, click the Confirm new API key button:
7. On the next page you will see your API key and Secret key. Remember to copy and paste your Secret Key somewhere safe, as it will not be shown again, due to security reasons. If you forget the Secret Key, you will need to delete the API key and then create a new one.
Step 4.) Add your Binance API URL into the Apipheny add-on
In this section, we show you how to enter your Binance API request into Apipheny. This section explains how to enter an API request that requires an API key. For API endpoints that don’t require an API key (section 3a.), you can just enter your URL into Apipheny and click “Run”.
Back in your Google Sheet, make sure the Apipheny add-on is open, on the “Import” tab.
After you’ve found the endpoint you need in Step 3, copy the complete URL into the API URL Path field in the Apipheny add-on, followed by any GET parameters required for your query (see screenshot below).
Here’s the example URL endpoint we used that requires an API key:
At the top of the add-on select the HTTP method (GET or POST) required by your API endpoint. For this example we are using GET.
Into the Headers section in Apipheny, you should add two rows with the following keys and values:
“your-API-key” is the value you got in Step 2.
The Accept and X-MBX-APIKEY headers are required, so you should add them in the dedicated table, below the API URL Path (JSON / CSV) field, like so:
It doesn’t matter what order you add the headers in.
Step 5.) Run the Binance API Request
Lastly, click the Run button at the bottom of the Apipheny add-on and then wait for the Binance API data to be imported into your Google Sheet.
After making a successful request to the Binance API, try querying a different endpoint, or try using one of the more advance features in the Apipheny add-on, such as:
- Save and schedule your API request
- Make a POST request (if available)
- Use the custom =APIPHENY() function to call the API request inside your spreadsheet
- Create an API request by referencing the value of a cell in the API URL with three curly braces eg. <<
>>
Источник