image_output_1.png
import json

import matplotlib.pyplot as plt

import pandas as pd

import requests

import seaborn as sns

token_address = '0xd7efb00d12c2c13131fd319336fdf952525da2af'
base_url = 'https://api.ethplorer.io'
url = base_url + f'/getTokenInfo/{token_address}?apiKey=freekey'
response = requests.get(url)
if response.status_code == 200:
    token_info_response = json.loads(response.text)
token_info_response

url = base_url + f'/getTopTokenHolders/{token_address}?apiKey=freekey&limit=100'
response = requests.get(url)
if response.status_code == 200:
    token_holders_response = json.loads(response.text)
token_holders_df = pd.DataFrame(token_holders_response['holders'])
n_top_holders_list = ['1', '2', '3', '5', '10', '25', '100']
shares_list = [round(token_holders_df['share'].values[:int(n)].sum(), 2) for n in n_top_holders_list]
plt.figure(figsize=(12, 6))
ax = sns.barplot(x=n_top_holders_list, y=shares_list, alpha=0.8, color=color[1])
ax.bar_label(ax.containers[0])
plt.xlabel('Top N Wallets', fontsize=12)
plt.ylabel('Cumulative percentage of Token share', fontsize=12)
plt.title('Percentage of tokens hodl by top N wallets', fontsize=16)
plt.show()