Recommendations By NFTs
Learn how to construct queries to build a recommendation engine based on NFTs held by the user(s).
NFTs tend to be built around the community or DAO members holding it and the holders of the same NFT likely have the same interests that can be a solid basis for contact recommendations.
Building such a contract recommendation feature based on NFTs takes two steps:
Query Get All NFTs Held By A User(s)
Using the array of NFTs returned from step 1, use it as an input to query Get All NFT Holders And Images Of An NFT Collection(s)
Airstack provides you the TokenBalances
API to fetch the NFT held by a user(s) and the TokenNFTs
API to fetch all the holders of a certain NFT collection.
Get All NFTs Held By A User(s)
First, you will fetch all the NFTs held by a user(s) to create the contact recommendation. All you need to provide the address
variable, which takes the user(s) address that the recommendation will be given to, to the following query:
Get All NFT Holders And Images Of An NFT Collection(s)
Once you have the list of NFT collections that was fetched from the first query above, you can format and compile the list of all NFT contract addresses and provide it as an address
input to the query below.
The query below will fetch all the NFT holdersâ web3 identities, which include the Ethereum addresses, ENS, Lens, and Farcasters.
In addition, the query will also fetch all NFT images that you can use to be displayed in your application.
Last updated