Search API Connector Documentation

Print

Import BscScan Data to Google Sheets

In this guide, we’ll walk through how to pull data from the BscScan API directly into Google Sheets, using the API Connector add-on for Sheets. We’ll first get an API key from BscScan, and then set up a request to pull in data to your spreadsheet.

CONTENTS

BEFORE YOU BEGIN

Click here to install the API Connector add-on from the Google Marketplace.

PART 1: GET YOUR BSCSCAN API KEY

Before we begin using the BscScan API, we will need to register and obtain our personal API key. Go here and register. After the registration, you will be redirected to your profile page. First, click on the API-KEYs section, and after that click on Add button to create your personal API key.

Name your API key and click on continue.

And your API key will appear!

PART 2: CREATE YOUR API REQUEST URL

We will create BscScan API requests based on the official documentation.

  • API root: https://api.bscscan.com/api?
  • Endpoints:
    • account
    • contract
    • transaction
    • block
    • logs
    • proxy
    • stats

PART 3: PULL BSCSCAN API DATA INTO GOOGLE SHEETS

In this section, we will show you how to run API link with account endpoint!

  1. Open up Google Sheets and click Add-ons > API Connector > Open.
  2. In the Create tab, we will specify API link with the address 0x0000000000000000000000000000000000001004 and action txlist, to get a list of ‘normal’ transactions by specified address. Constructed API URL should look like this:
https://api.bscscan.com/api?module=account&action=txlist&address=0x0000000000000000000000000000000000001004&apikey=YOUR-API-KEY

3. Now create a new tab, give it a name and click Set current to use that tab as your data destination.

4. Give a name to your request and click run!

5. Now the pulled data will appear in your sheets.

PART 4: MORE EXAMPLE API URLS

Here we will present more API URL examples. We encourage you to go through the BscScan documentation for constructing even more examples!

  • Get sorted list of ‘Normal’ Transactions by Address:
https://api.bscscan.com/api?module=account&action=txlist&address=0x0000000000000000000000000000000000001004&sort=asc&apikey=YOUR-API-KEY
  • Get sorted list of ‘Internal’ Transactions by Address:
https://api.bscscan.com/api?module=account&action=txlistinternal&address=0x0000000000000000000000000000000000001004&startblock=0&endblock=2702578&sort=asc&apikey=YOUR-API-KEY
  • Get “Internal” Transactions by block range:
https://api.bscscan.com/api?module=account&action=txlistinternal&startblock=0&endblock=2702578&page=1&offset=10&sort=asc&apikey=YOUR-API-KEY
  • Get Estimated Block Countdown Time by BlockNo:
https://api.bscscan.com/api?module=block&action=getblockcountdown&blockno=8000000&apikey=YOUR-API-KEY
  • Get Block Number by Timestamp:
https://api.bscscan.com/api?module=block&action=getblocknobytime&timestamp=1601510400&closest=before&apikey=YOUR-API-KEY
  • Check Transaction Receipt Status:
https://api.bscscan.com/api?module=transaction&action=gettxreceiptstatus&txhash=0xe9975702518c79caf81d5da65dea689dcac701fcdd063f848d4f03c85392fd00&apikey=YOUR-API-KEY
  • Get Total Supply of BNB on the Binance Smart Chain:
https://api.bscscan.com/api?module=stats&action=bnbsupply&apikey=YOUR-API-KEY
  • Get BNB Last Price:
https://api.bscscan.com/api?module=stats&action=bnbprice&apikey=YOUR-API-KEY
  • Get Validators list on the Binance Smart Chain:
https://api.bscscan.com/api?module=stats&action=validators&apikey=YOUR-API-KEY

PART 5: PAGINATION

BscScan API limits 10 000 responses per page. This can be handled with parameters:  

  • page=<page number>
  • offset=<max records to return, default value=10 000>

To access more than 10 000 records, add the page and offset parameters like this:

https://api.bscscan.com/api?module=account&action=txlist&address=0x0000000000000000000000000000000000001004&startblock=1&endblock=99999999&page=1&offset=10000&sort=asc&apikey=YOUR-API-KEY
https://api.bscscan.com/api?module=account&action=txlist&address=0x0000000000000000000000000000000000001004&startblock=1&endblock=99999999&page=2&offset=10000&sort=asc&apikey=YOUR-API-KEY

Please note: as the offset default value is 10000, you can exlude it from examples above!

Automatic pagination handling

Pagination can be handled automatically with the pagination handling feature, like this:

  • API Request URLenter your request URL as usual, e.g. 
https://api.bscscan.com/api?module=account&action=txlist&address=0x0000000000000000000000000000000000001004&startblock=1&endblock=99999999&sort=asc&apikey=YOUR-API-KEY
  • Pagination typepage parameter
  • Page parameter: page
  • Number of pages: enter the number of pages you’d like to fetch

PART 6: LIMITATIONS

Rate limit of 5 calls per sec/IP.

Leave a Comment