Import Binance Data to Google Sheets

In this guide, we’ll walk through how to pull cryptocurrency market data from the Binance API directly into Google Sheets, using the API Connector add-on for Sheets. For this example we’ll only access Binance’s open, unauthenticated endpoints, so we don’t need to get an API key.

If you don’t want to read all the details, feel free to skip ahead to the Binance template!

PART 1: CREATE YOUR API REQUEST URL

We’ll first follow the Binance API documentation to access the latest order book data for a pair of currencies.

  • API root: https://api.binance.com
  • Endpoint: /api/v1/depth
  • Query String: ?symbol=CURRENCY_PAIR

Just substitute in your own currency pair. Putting it together, we get the full API Request URL:

https://api.binance.com/api/v1/depth?symbol=BTCUSDT

PART 2: PULL BINANCE API DATA INTO SHEETS

We can now enter all our values into API Connector and import Binance API data into Google Sheets.

  1. Open up Google Sheets and click Add-ons > API Connector > Open.
  2. In the Create tab, enter the Request URL we just created
    binance-img1
  3. Leave the Headers section empty. The market data part of the Binance API is public, so we don’t need any headers here. We don’t need extra Authentication either so leave that set to None.
  4. Create a new tab and click ‘Set current’ to use that tab as your data destination.
  5. From the Output Options menu, select the ‘compact’ report style.
    binance-img2

    Note that we select compact style because Binance sends API data in a series of arrays, and API Connector’s default parsing method will place these values into separate columns. The compact style enables each array to appear in a new row instead. (More on report styles here: Report Styles).

  6. Name your request and click Run. A moment later you’ll see the latest bid and ask market data for USD to BTC appear in your Google Sheet:binance-img3
If you want to convert Binance’s timestamp to a human readable date, use the following formula in Sheets:

=({Sheet!Cell}/1000)/86400+date(1970,1,1)

PART 3: GET MORE BINANCE API DATA

  1. Experiment with query strings as described in the documentation to see other types of crypto data from the API. For example, you can see trade history with the /trades endpoint:
    https://api.binance.com/api/v1/trades?symbol=BTCUSDT
    binance-img4
  2. Other Binance endpoints like /api/v1/historicalTrades require an API key. You can retrieve this from the API Management section of your account, and enter it into the Headers section of API Connector with a Header key of X-MBX-APIKEY
    binance-img5

PART 4: HANDLE PAGINATION

By default, Binance will return a certain number of records, usually 500. To return more (or fewer) records, change the ‘limit’ parameter, e.g.

https://api.binance.com/api/v1/trades?symbol=BTCUSDT&limit=10

APPENDIX: BINANCE DASHBOARD

If you want to skip all the URL entry and research, head over to our pre-built OHLC template and input your own Base/Quote pairs.

binance-img6

Leave a Comment