Learn how to get recommended followers for Farcaster users based on on-chain insights from token transfers, POAPs, NFTS, and token holder combinations.
provides easy-to-use APIs for enriching applications and for integrating onchain and offchain data with Farcaster.
In this tutorial, you will learn how to recommend followers for Farcaster users based on on-chain insights from token transfers, POAPs, NFTS, and token holder combinations.
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
};
The follow recommendation will provide a list of Farcaster users with the Farcaster user name from the profileName field and Farcaster user ID from the userId field.
Get Recommendation Follows For Farcaster User(s) Based on NFTs
To get recommendations by NFTs, first fetch all NFTs that is owned by the Farcaster user(s) on both Ethereum and Polygon:
The follow recommendation will provide a list of Farcaster users with the Farcaster user name from the profileName field and Farcaster user ID from the userId field.
Get Recommendation Follows For Farcaster User(s) Based on NFTs and POAPs Commonly Held
Fetching
You can fetch follow recommendations based on the common holder of a specific NFT and a specific POAP by providing the token contract address and the POAP event ID:
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.
If you have any questions or need help regarding building a recommendation engine, please join our Airstack's group.