defformat_function(data): result = []if data isnotNoneand'TokenBalances'in data and'TokenBalance'in data['TokenBalances']:for item in data['TokenBalances']['TokenBalance']:if'owner'in item and'tokenBalances'in item['owner']:for token_balance in item['owner']['tokenBalances']:if'owner'in token_balance and'xmtp'in token_balance['owner']and token_balance['owner']['xmtp'].get('isXMTPEnabled', False)and'addresses'in token_balance['owner']: result.append(token_balance['owner']['addresses']) result = [item for sublist in result for item in sublist] result = [item for sublist in result for item in sublist] result =list(set(result))return result
The final result will the the list of all common holders in an array:
defformat_function(data): result = []if data isnotNoneand'TokenBalances'in data and'TokenBalance'in data['TokenBalances']:for item in data['TokenBalances']['TokenBalance']:if'owner'in item and'tokenBalances'in item['owner']:for token_balance in item['owner']['tokenBalances']:if'owner'in token_balance and'socials'in token_balance['owner']andlen(token_balance['owner']['socials'])>0and'addresses'in token_balance['owner']: result.append(token_balance['owner']['addresses']) result = [item for sublist in result for item in sublist] result = [item for sublist in result for item in sublist] result =list(set(result))return result
The final result will the the list of all common holders in an array:
defformat_function(data): result = []if data isnotNoneand'TokenBalances'in data and'TokenBalance'in data['TokenBalances']:for item in data['TokenBalances']['TokenBalance']:if'owner'in item and'tokenBalances'in item['owner']:for token_balance in item['owner']['tokenBalances']:if'owner'in token_balance and'socials'in token_balance['owner']andlen(token_balance['owner']['socials'])>0and'addresses'in token_balance['owner']: result.append(token_balance['owner']['addresses']) result = [item for sublist in result for item in sublist] result = [item for sublist in result for item in sublist] result =list(set(result))return result
The final result will the the list of all common holders in an array: