Mapping ecosystem - Issue w/ Glacier API Rate Limiting

I was trying to get a script to run in Glacier and hit the limiting. Would appreciate some help in approaching this so I can accomplish my goal. I am trying to create a script that will allow me to select an ERC20 address and identify the smart contracts that have interacted with it. This will allow me to then start mapping out the interactions within the ecosystem.

I then found myself blocked by Cloudflare. I am assuming I made too many requests in one of the tests. Would appreciate direction on how to mitigate hitting this wall and insight on how I can improve my script.

import requests

def get_transfers(erc20_address, api_key):
    url = f"https://glacier-api.avax.network/v1/chains/43114/tokens/{erc20_address}/transfers?pageSize=10"
    response = requests.get(url)
    if response.status_code != 200:
        print(f"Error with status code {response.status_code} and text: {response.text}")
        return
    try:
        data = response.json()
    except ValueError:
        print(f"No JSON object could be decoded from the response: {response.text}")
        return
    transfers = data["transfers"]
    
    for transfer in transfers:
        from_address = transfer["from"]["address"]
        to_address = transfer["to"]["address"]
        
        # Check if the from_address or to_address is a contract
        if is_contract(from_address, api_key) or is_contract(to_address, api_key):
            print(f"Transaction hash: {transfer['txHash']}")
            print(f"From address: {from_address}")
            print(f"To address: {to_address}")
            print("------")

def is_contract(address, api_key):
    url = f"https://api.snowtrace.io/api?module=proxy&action=eth_getCode&address={address}&tag=latest&apikey={api_key}"
    response = requests.get(url)
    if response.status_code != 200:
        print(f"Error with status code {response.status_code} and text: {response.text}")
        return
    try:
        data = response.json()
    except ValueError:
        print(f"No JSON object could be decoded from the response: {response.text}")
        return
    code = data["result"]

    return code != '0x'


# Enter your ERC20 token address and SnowTrace API key here - using lost as an example
erc20_address = "0x449674B82F05d498E126Dd6615a1057A9c088f2C"
api_key = ""
get_transfers(erc20_address, api_key)

Hey Jomari,

We intend to release higher rate limit tiers for Glacier in the future. In the meantime, your best bet is to space out requests as much as you can to avoid hitting the threshold.

1 Like