API Connector Documentation
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
- Part 1: Get Your BscScan API KEY
- Part 2: Pull Data from BscScan into Sheets
- Part 3: Create a Custom API Request
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get Your BscScan API Key
- While logged into BscScan, open the Account menu dropdown and click API Keys
- In the API Keys menu click Add
- Name your API key and click Continue.
- You will now see your API key, copy it down and keep it safe as we'll need it shortly.
Part 2: Pull Data from BscScan into Sheets
The easiest way to get started with the BscScan API is through API Connector’s built-in integration.
- In Sheets, open API Connector and create a new request (Extensions > API Connector > Open > Create request)
- Select BscScan from the drop-down list of applications
- Choose an endpoint. We'll start with the endpoint for fetching 'normal' transactions.
- In the parameters section, enter your API key and the address of interest.
- Choose a destination sheet, name your request, and hit Run to see the response data in your sheet.
- That's it! If you like, you can double-check that the data in your sheet matches the data you see when you search BscScan's search box by address. It should be exactly the same:
Part 3: Create a Custom API Request
Alternatively, you can run your own custom requests instead of using API Connector’s pre-built integration, using any of the URLs shown in the API documentation. Here's an example request configuration:
- Application:
Custom
- Method:
GET
- Request URL:
https://api.bscscan.com/api?module=account&action=txlist&address=0xea0A6E3c511bbD10f4519EcE37Dc24887e11b55d&startblock=0&endblock=99999999&sort=desc&apikey=1111111111
- OAuth:
None
Part 4: API Documentation
Official API documentation: https://docs.bscscan.com/
Hi Ana, What i'm trying to do is to extract all the data in a specific period (like from 01/12/2021 to 10/12/2021) from a specific contract without restriction of 5000 records for example if try to do it there is a limitation (for example -->
https://bscscan.com/exportData?type=address&a=0x6d6ba21e4c4b29ca7bfa1c344ba1e35b8dae7205
)Resuming - >I need to analyze all the transactions from a specific contract without limit of 5000 records max.
I've seen the API also has a limit of 10.000 records..
Thanks in advance!
Hey Paul, a request URL Like
https://api.bscscan.com/api?module=account&action=txlist&address=0x6d6ba21e4c4b29ca7bfa1c344ba1e35b8dae7205&startblock=0&endblock=99999999&sort=desc&apikey=YOUR_KEY
should get you what you're looking for. It will send 10,000 records into your sheet.Hey Ana,
I did just like you answered to Paul to get 10,000 records of transactions of a particular token, but it's missing the DateTime and Method fields (which you get when you download it as .cvs export file from BSSCAN)
Am i missing something or should i put another request url ? If so which one cause i can't seem to find the correct one.
Thanks for your answer.
I think that's just how BscScan returns data, they didn't set their API to produce exactly the same output as their CSV exports. Instead of a DateTime field, the API returns a timeStamp field, which contains the date and time as a UNIX timestamp. To convert it, you can set your data destination to cell B1 and enter the following function into cell A1 (info):
=arrayformula(if(E2:E<>"",EPOCHTODATE(E2:E,1),""))
. That function will convert all the UNIX timestamps in column E to regular Sheets dates. (If the values initially look like45077
, use the Sheets format menu to display them as dates).As for the Method field, when I test this API request I see a field called functionName with values like "transfer" and "approve". That looks like the method to me, or are you looking for something else?
Hey Ana,
I reply to your message from May 31, 2023 at 4:36 am (there's no reply button at the end of that message)
Thanks for your answer and the unix timestamp conversion procedure.
For the method field, i'm looking for add liquidity, swap, lock, multicall... (the one ones you get with .cvs)
Ah I see, looks like they don't provide that, but I can't say for sure. You can contact BscScan's technical support to confirm.
Hey Ana,
I think i'll stick with .cvs, probably easier and has what i look for.
Thanks for your work and taking the time to answer !
bom eu gostaria de um script mais simples
eu tenho algumas moedas de jogo que possuo
queria listas essas moedas e cota-las apenas
em USDT, ETH, BNB e BRL
Seria possível, um scrip para encerrir as moedas que preciso nessas 4 cotações
Google Translate wasn't that clear here but if you just want exchange rates for those 4 currencies, you can use any API that provides crypto market data. Here's a list of some popular ones.
Is it possible to use this as a way to determine how many holders and what they hold?
Looks like it's not, you can see some other discussions about it here and here.
Hi I am trying to pull in about 360000 transactions how to proceed this API sends only 10k Transactions
Their documentation says “This API endpoint returns a maximum of 10000 records only.” I tested and confirmed that you can’t get more than 10k transactions, even if you apply pagination parameters. Can you split up your request to ensure each request is below their limit?
This is a very well made instructions, thank you for sharing the knowledge.
However, I can't get the token transfer table (BEP-20) from a specific address. When I try to run your example (replacing the addres and API), it gives me "no transactions found"
https://api.bscscan.com/api?module=account&action=txlist&address=0x00000000000000000000000000000&startblock=0&endblock=99999999&sort=desc&apikey=APIHERE
Any idea?
You'll need to use the "Get a list of 'BEP-20 Token Transfer Events' by Address" endpoint as described here. Basically you just need to use an action of tokentx instead of txlist, so this URL should work:
https://api.bscscan.com/api?module=account&action=tokentx&address=0x569d67ab8Bf133f3aC6D97D3322bEc7972F2A69B&startblock=0&endblock=999999999&sort=asc&apikey=111111111111111
Good afternoon Anna, great article!!
I'm starting my studies, I'm interested in doing a project for college, in it I want to study on the purchase and sale data of a certain currency. Can you tell me if in the API I can have access in addition to HASH, purchase, sale and quantity, I want to have access to the portfolios to build an investor profile.
Sorry, my english is not the best
I'm not sure I totally understand your question, but I think you might be asking how to get the token holdings of a particular wallet?
In that case you could run a request URL to get token balances, specifying the contract token address and the address you're interested in, like this:
https://api.bscscan.com/api?module=account&action=tokenbalance&contractaddress=0xe9e7cea3dedca5984780bafc599bd69add087d56&address=0x89e73303049ee32919903c09e8de5629b84f59eb&tag=latest&apikey=1111111111111
You would need to repeat that for each token contract address.
Hi Ana,
I want to download all the transactions of a coin involved in a scam for my thesis and stumbled upon this page. I see you mentioned a couple of times that this method limits the download to 10k records. Is there a way to download all of the records of a coin for a given date range? Thanks!
I don't think all endpoints have that limit. But either way, you can always limit the date range such that each pull has less than 10K records in it.
Hi Ana,
Please i want to know where can i find the approvals that have been made for a specific ERC20 token, for example i've approved for my testing wallet to spend some tokens i tried to find the transaction using just my receiving wallet address but i didn't find the transaction in bscscan so i think i can find it using api.
Thank you!
Sorry, I'm not really familiar with this, can you please look through https://docs.bscscan.com/ for the endpoint you need? Once you find the right endpoint I can help you run it.
Hello Ana,
It's on the accounts section.
Great, almost all the Account endpoints are in the BscScan integration. So just click API Connector's application dropdown menu, search for BscScan, and then select the endpoint you need from the endpoint menu, e.g. "Get BEP-20 Token transfer events" or "Get normal transactions" etc. You'll need to enter your API key in the
apikey
parameter, which you can get as described here.Hi Ana,
Thank you for the great info and explanation.
I have a question on creating a different query (custom):
I want to get all the output of all Blocks created during a certain time period, without the limitation to a certain block number.
The variables I would like to see the output are:
Timestamp
Block
Transactions count
Miner
Block Reward in BNB
Equivalent Fiat (USD) reward
Where date between say June 1/22 to June 30/22.
Can this be done with the API?
Thank you.
I don't see all those metrics available via the API. This is the closest I found: https://docs.bscscan.com/api-pro/api-pro#get-daily-block-count-and-rewards. You can check through their other endpoints, it looks like their API PRO endpoints are the ones with block-related stats.