Learn how to get all Lens profiles who own a specific token, NFT, or POAP, or a min amount of that token. Get combinations of NFTs or POAPs + Lens, e.g. Has POAP1 and POAP2 and has Lens profile
provides easy-to-use APIs for enriching applications and integrating on-chain and off-chain data with .
In this tutorial, you will learn how to fetch all Lens profiles that own a specific ERC20 token, NFT (ERC721 and ERC1155), or POAPs.
In addition, you will also learn how to fetch common Lens profiles that hold two different assets at the same time, e.g. Lens profiles that hold both and POAP.
In this guide you will learn how to use Airstack to:
Pre-requisites
An account (free)
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
React
npm install @airstack/airstack-react
Node
npm install @airstack/node
React
yarn add @airstack/airstack-react
Node
yarn add @airstack/node
React
pnpm install @airstack/airstack-react
Node
pnpm install @airstack/node
pip install airstack asyncio
Then, add the following snippets to your code:
import { init, useQuery } from "@airstack/airstack-react";
init("YOUR_AIRSTACK_API_KEY");
const query = "YOUR_QUERY"; // Replace with GraphQL Query
const Component = () => {
const { data, loading, error } = useQuery(query);
if (loading) {
return <p>Loading...</p>;
}
if (error) {
return <p>Error: {error.message}</p>;
}
// Render your component using the data returned by the query
};
def format_function(data):
result = []
if data and 'TokenBalances' in data and 'TokenBalance' in data['TokenBalances']:
for item in data['TokenBalances']['TokenBalance']:
if 'owner' in item and 'socials' in item['owner'] and len(item['owner']['socials']) > 0:
result.append(item['owner']['socials'])
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:
def format_function(data):
result = []
if data and 'TokenBalances' in data and 'TokenBalance' in data['TokenBalances']:
for item in data['TokenBalances']['TokenBalance']:
if 'owner' in item and 'socials' in item['owner'] and len(item['owner']['socials']) > 0:
result.append(item['owner']['socials'])
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:
def format_function(data):
result = []
if data and 'Poaps' in data and 'Poap' in data['Poaps']:
for item in data['Poaps']['Poap']:
if 'owner' in item and 'socials' in item['owner'] and len(item['owner']['socials']) > 0:
result.append(item['owner']['socials'])
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:
def format_function(data):
result = []
if data and 'TokenBalances' in data and 'TokenBalance' in data['TokenBalances']:
for item in data['TokenBalances']['TokenBalance']:
if 'owner' in item and 'socials' in item['owner'] and len(item['owner']['socials']) > 0:
result.append(item['owner']['socials'])
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:
def format_function(data):
result = []
if data and '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'] and len(token_balance['owner']['socials']) > 0:
result.append(token_balance['owner']['socials'])
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:
def format_function(data):
result = []
if data and 'Poaps' in data and 'Poap' in data['Poaps']:
for poap in data['Poaps']['Poap']:
if 'owner' in poap and 'poaps' in poap['owner']:
for owner_poap in poap['owner']['poaps']:
if 'owner' in owner_poap and 'socials' in owner_poap['owner'] and len(owner_poap['owner']['socials']) > 0:
result.append(owner_poap['owner']['socials'])
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:
def format_function(data):
result = []
if data is not None and 'TokenBalances' in data and 'TokenBalance' in data['TokenBalances']:
for item in data['TokenBalances']['TokenBalance']:
if 'owner' in item and 'poaps' in item['owner']:
for poap in item['owner']['poaps']:
if 'owner' in poap and 'socials' in poap['owner']:
result.append(poap['owner']['socials'])
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:
To access the Airstack APIs in other languages, you can use as your GraphQL endpoint.
đ¤ AI Natural Language
provides an AI solution for you to build GraphQL queries to fulfill your use case easily. You can find the AI prompt of each query in the demo's caption or title for yourself to try.
You can fetch the common holders of two given ERC20, e.g. and :
You can fetch the common holders of two given POAP event IDs, e.g. & :
If you have any questions or need help regarding fetching holders or attendees of multiple POAPs, please join our Airstack's group.