I need to filter ethplorer’s api results

  api, cryptocurrency, python

I am trying to build a list of the top holders for several coins, excluding exchanges addresses and I would like to know if it is possible to do that?
Here is my code:

import requests

ripio_credit_network = {
      'name': 'ripio-credit-network',
      'address': '0xF970b8E36e23F7fC3FD752EeA86f8Be8D83375A6'
}
ripio_contract_adress = ripio_credit_network['address']
num_of_accounts_to_track = 42
target_domain = 'https://api.ethplorer.io/'

def top_token_holders(num_of_holders, coin_address):
    """take a coin adress and return the top X addresses as a reponse.json from api"""

    top_token_request = f"{target_domain}" 
                        f"getTopTokenHolders/" 
                        f"{coin_address}?" 
                        f"apiKey={freekey}" 
                        f"&limit={num_of_holders}" 

    response = requests.get(top_token_request)
    return response.json()

def top_holders_list(number_to_track, coin_address):
    """take addresses and share from an api call & returns list of dictionaries"""

    the_data = top_token_holders(number_to_track, coin_address)
    top_coin_holders = []
    cols = ['address', 'share']

    for i in range(0, number_to_track):
        new_empty_dict = dict()
        for col in cols:
            if col == 'address':
                new_empty_dict[col] = the_data['holders'][i]['address']
            elif col == 'share':
                new_empty_dict[col] = the_data['holders'][i]['share']

        top_coin_holders.append(new_empty_dict)

    return top_coin_holders

top_holders_ripio = top_holders_list(num_of_accounts_to_track, ripio_contract_adress)

This returns the top holders and I would like to filter out the exchanges addresses (like showing in this image)Ripio top holders showing exchange addresses

Is there a way to do that?

Source: Python Questions

LEAVE A COMMENT