Import Binance Data to Google Sheets

Import Binance Data to Google Sheets

Last Updated On October 13, 2019

Binance is a cryptocurrency trading and tracking platform. In this guide, we’ll walk through how to pull cryptocurrency market data from the Binance API directly into Google Sheets, using the free API Connector add-on

PART 1: CREATE YOUR API REQUEST URL

We’ll 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}}
    Query String Example: ?symbol=BTCUSDT

Putting it together, we get the full API Request URL:
https://api.binance.com/api/v1/depth?symbol=BTCUSDT

PART 2: ENTER YOUR VALUES INTO API CONNECTOR

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 > Create New API Request.
  2. In the Create Request interface, 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.
  4. Create a new tab. You can call it whatever you like, but here we’ll call it ‘Binance_Depth’. While still in that tab, click ‘Set’ 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 like this:

    API Connector’s default parsing method attempts to flatten out JSON by placing nested values into separate columns. In this case, the compact style enables each array to appear in a new row instead. More on report styles here: Report Styles

  6. Name your request. Again we’ll call it ‘Binance_Depth’
  7. Click Run and a moment later you’ll see the latest bid and ask market data for USD to BTC appear in your Google Sheet:
    binance-img3

PART 3: NOTES AND EXPANSIONS

  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. 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.
  3. 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

Comments:0

Leave a Reply

Your email address will not be published.