At the time of creating this topic there are 8612 tokens in BSC network. I am using below query to get the token count.
{
ethereum(network: bsc) {
smartContractCalls(
smartContractMethod: {is: "Contract Creation"}
smartContractType: {is: Token}
) {
count
}
}
}
{
"ethereum": {
"smartContractCalls": [
{
"count": 8612
}
]
}
}
When I am trying to extract details of all these 8612 tokens using the below query I am getting details of only 1632. Below is the query I am using to fetch the token details.
{
ethereum (network: bsc) {
smartContractCalls(options: {desc: "block.height", limit:9000},
smartContractMethod: {is: "Contract Creation"},
smartContractType: {is: Token}) {
block {
height
timestamp {
time
}
}
smartContract {
contractType
address {
address
annotation
}
currency {
name
symbol
decimals
tokenType
}
}
}
}
}
I am using python program. Below is my python program. Could you please take a look into this and suggest why I am not getting details of all the tokens and getting only a subset of it?
import requests
import pandas as pd
def run_query(query): # A simple function to use requests.post to make the API call.
headers = {'X-API-KEY': 'BQYLmKg5GuCEyddqMoZVYcdQgvRp3I0M'}
request = requests.post('https://graphql.bitquery.io/',
json={'query': query}, headers=headers)
print('[+] Getting details from BSCSCAN. Please wait.')
if request.status_code == 200:
return request.json()
else:
raise Exception('[+] Query failed and return code is {}. {}'.format(request.status_code,query))
query ="""
{
ethereum (network: bsc) {
smartContractCalls(options: {desc: "block.height", limit:9000},
smartContractMethod: {is: "Contract Creation"},
smartContractType: {is: Token}) {
block {
height
timestamp {
time
}
}
smartContract {
contractType
address {
address
annotation
}
currency {
name
symbol
decimals
tokenType
}
}
}
}
}
"""
result = run_query(query) # Execute the query
bscscan = result['data']['ethereum']['smartContractCalls']
print("[+]Number of tokens returned >>> ",len(bscscan))
rows=[]
row_data = {}
count = 0
for item in bscscan:
row_data['address'] = item['smartContract']['address']['address']
row_data['timeStamp'] = item['block']['timestamp']['time']
row_data['currency_name']=item['smartContract']['currency']['name']
rows.append(row_data.copy())
bscscan_df = pd.DataFrame(rows)
bscscan_df.to_excel("bscscan_0516.xlsx")