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 ERC20, NFTs, or POAPs in common from multiple Lens profiles.
In this guide you will learn how to use Airstack to:
Pre-requisites
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Copy pip install airstack asyncio
Then, add the following snippets to your code:
React Node Python
Copy 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
};
Copy import { init, fetchQuery } from "@airstack/airstack-react";
init("YOUR_AIRSTACK_API_KEY");
const query = "YOUR_QUERY"; // Replace with GraphQL Query
const { data, error } = fetchQuery(query);
console.log("data:", data);
console.log("error:", error);
Copy import asyncio
from airstack.execute_query import AirstackClient
api_client = AirstackClient(api_key="YOUR_AIRSTACK_API_KEY")
query = "YOUR_QUERY" # Replace with GraphQL Query
async def main():
execute_query_client = api_client.create_execute_query_object(
query=query)
query_response = await execute_query_client.execute_query()
print(query_response.data)
asyncio.run(main())
Other Programming Languages
ERC20 Tokens In Common Owned By Lens Profile(s)
You can fetch common ERC20 tokens of multiple Lens profiles:
Try Demo
Code
Query Response
Copy query MyQuery {
TokenBalances(
input: {filter: {owner: {_eq: "bradorbradley.lens"}, tokenType: {_eq: ERC20}}, blockchain: polygon}
) {
TokenBalance {
token {
tokenBalances(
input: {filter: {owner: {_eq: "christina.lens"}, tokenType: {_eq: ERC20}}}
) {
id
token {
address
symbol
name
}
}
}
}
}
}
Copy {
"data": {
"TokenBalances": {
"TokenBalance": [
{
"token": {
"tokenBalances": [
{
"id": "bd292d232f10973466326db331c17ca93bff3be12fec404dc6b611001caacac9",
"token": {
"address": "0x086373fad3447f7f86252fb59d56107e9e0faafa",
"symbol": "YUP",
"name": "Yup"
}
}
]
}
},
{
"token": {
"tokenBalances": [] // Owned by bradorbradley.lens, but not owned by christina.lens
}
}
]
}
}
}
NFTs In Common Owned By Lens Profile(s)
You can fetch common NFTs of multiple Lens profile(s):
Try Demo
Code
Query Response
Copy query MyQuery {
TokenBalances(
input: {filter: {owner: {_eq: "bradorbradley.lens"}, tokenType: {_in: [ERC721, ERC1155]}}, blockchain: polygon}
) {
TokenBalance {
token {
tokenBalances(
input: {filter: {owner: {_eq: "christina.lens"}, tokenType: {_in: [ERC721, ERC1155]}}}
) {
id
token {
address
symbol
name
}
}
}
}
}
}
Copy {
"data": {
"TokenBalances": {
"TokenBalance": [
{
"token": {
"tokenBalances": [
{
"id": "d51975aef4b2c638e9045bfd59f984035c49c0452bca092d1bc79ce5143b395a",
"token": {
"address": "0x5c9d8fcd43847af51810cdfaeabee4ffad82d331",
"symbol": "meyt-Fl",
"name": "meytab.lens-Follower"
}
}
]
}
},
{
"token": {
"tokenBalances": [] // Owned by bradorbradley.lens, but not owned by christina.lens
}
}
]
}
}
}
POAPs In Common Owned Lens Profile(s)
You can fetch common POAPs of multiple Lens profile(s):
Try Demo
Code
Query Response
Copy query MyQuery {
Poaps(
input: {filter: {owner: {_eq: "bradorbradley.lens"}}, blockchain: ALL, order: {createdAtBlockNumber: DESC}}
) {
Poap {
poapEvent {
poaps(input: {filter: {owner: {_eq: "christina.lens"}}}) {
poapEvent {
eventName
eventId
endDate
country
city
}
}
}
}
}
}
Copy {
"data": {
"Poaps": {
"Poap": [
{
"poapEvent": {
"poaps": [
{
"poapEvent": {
"eventName": "Avara Genesis Fam",
"eventId": "105708",
"endDate": "2023-02-24T00:00:00Z",
"country": "",
"city": ""
}
}
]
}
},
{
"token": {
"tokenBalances": [] // Owned by bradorbradley.lens, but not owned by christina.lens
}
}
]
}
}
}
Developer Support
More Resources