👉 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.
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:
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.
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” 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.
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:
|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.|
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
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=<your_symbol>
When using this endpoint, do not forget to replace <your_symbol> 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=<your_symbol>
Do not forget to replace <your_symbol> with an actual symbol. I choose ETHBTC value for this example:
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.
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:
Into the Headers section in Apipheny, you should add two rows with the following keys and values:
Key 1: Accept Value 1: application/json
“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.
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: