đ Farcaster FollowingLearn how to fetch Farcaster following data and its various use cases and combinations.
Airstack provides easy-to-use APIs for enriching Farcaster applications and integrating on-chain and off-chain data with Farcaster.
Table Of Contents
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
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 (data) {
return < p >Data: { JSON .stringify (data)}</ p >;
}
if (loading) {
return < p >Loading...</ p >;
}
if (error) {
return < p >Error: { error .message}</ p >;
}
};
Copy import { init , fetchQuery } from "@airstack/node" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const { data , error } = await 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
To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
Get Farcaster Following of Farcaster User(s)
You can get the list of Farcaster following of Farcaster user(s) by inputting 0x address , ENS domain, Farcaster Name , or Farcaster ID:
Try Demo
Code
Query Response
Copy query MyQuery {
SocialFollowings(
input: {
filter : {
dappName : { _eq : farcaster }
identity : {
_in : [
"fc_fname:dwr.eth"
"fc_fid:602"
"varunsrin.eth"
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
]
}
}
blockchain : ALL
limit : 200
}
) {
Following {
followingAddress {
addresses
socials(input: { filter : { dappName : { _eq : farcaster } } }) {
profileName
userId
userAssociatedAddresses
}
}
followingProfileId
followerAddress {
addresses
domains {
name
}
socials(input: { filter : { dappName : { _eq : farcaster } } }) {
profileName
userId
userAssociatedAddresses
}
}
followerProfileId
}
}
}
Copy {
"data" : {
"SocialFollowings" : {
"Following" : [
{
"followingAddress" : {
"addresses" : [
"0x5beaf49e8ee203ef1023e9b1b716c07016f399a1" ,
"0x223f2db258234f7fa164a9e4c0929318feb3b550"
] ,
"socials" : [
{
"profileName" : "vm" ,
"userId" : "325" ,
"userAssociatedAddresses" : [
"0x5beaf49e8ee203ef1023e9b1b716c07016f399a1" ,
"0x223f2db258234f7fa164a9e4c0929318feb3b550"
]
}
]
} ,
"followingProfileId" : "325" ,
"followerAddress" : {
"addresses" : [
"0x74232bf61e994655592747e20bdf6fa9b9476f79" ,
"0xb877f7bb52d28f06e60f557c00a56225124b357f" ,
"0xa14b4c95b5247199d74c5578531b4887ca5e4909" ,
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2"
] ,
"domains" : [
{
"name" : "dwr.eth"
} ,
{
"name" : "noun124.eth"
} ,
{
"name" : "dwr.mirror.xyz"
} ,
{
"name" : "danromero.eth"
}
] ,
"socials" : [
{
"profileName" : "dwr.eth" ,
"userId" : "3" ,
"userAssociatedAddresses" : [
"0x74232bf61e994655592747e20bdf6fa9b9476f79" ,
"0xb877f7bb52d28f06e60f557c00a56225124b357f" ,
"0xa14b4c95b5247199d74c5578531b4887ca5e4909" ,
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2"
]
}
]
} ,
"followerProfileId" : "3"
}
// more following
]
}
}
}
Get The Most Recent Farcaster Following of Farcaster User(s)
You can get the list of most recent Farcaster following of Farcaster user(s) by inputting 0x address , ENS domain, Farcaster Name , or Farcaster ID:
Try Demo
Code
Query Response
Copy query MyQuery {
SocialFollowings(
input: {
filter : {
dappName : { _eq : farcaster }
identity : {
_in : [
"lens/@stani"
"lens_id:0x024"
"vitalik.eth"
"0xeaf55242a90bb3289dB8184772b0B98562053559"
]
}
}
blockchain : ALL
limit : 200
order : { followerSince : DESC }
}
) {
Following {
followingAddress {
addresses
socials(input: { filter : { dappName : { _eq : farcaster } } }) {
profileName
profileTokenId
profileTokenIdHex
}
}
followingProfileId
followerAddress {
addresses
domains {
name
}
socials(input: { filter : { dappName : { _eq : farcaster } } }) {
profileName
profileTokenId
profileTokenIdHex
}
}
followerProfileId
followerTokenId
}
}
}
Get The Earliest Farcaster Following of Farcaster User(s)
You can get the list of the earliest Farcaster following of Farcaster user(s) by inputting 0x address , ENS domain, Farcaster Name , or Farcaster ID:
Try Demo
Code
Query Response
Copy query MyQuery {
SocialFollowings(
input: {
filter : {
dappName : { _eq : farcaster }
identity : {
_in : [
"lens/@stani"
"lens_id:0x024"
"vitalik.eth"
"0xeaf55242a90bb3289dB8184772b0B98562053559"
]
}
}
blockchain : ALL
limit : 200
order : { followerSince : ASC }
}
) {
Following {
followingAddress {
addresses
socials(input: { filter : { dappName : { _eq : farcaster } } }) {
profileName
profileTokenId
profileTokenIdHex
}
}
followingProfileId
followerAddress {
addresses
domains {
name
}
socials(input: { filter : { dappName : { _eq : farcaster } } }) {
profileName
profileTokenId
profileTokenIdHex
}
}
followerProfileId
followerTokenId
}
}
}
Get Farcaster Following of Farcaster User(s) that has ENS Domain
You can get the list of Farcaster following of Farcaster user(s) and check if they have any ENS domain by inputting 0x address , ENS domain, Farcaster Name , or Farcaster ID:
Try Demo
Code
Query
Copy query MyQuery {
SocialFollowings(
input: {filter: {dappName: {_eq: farcaster}, identity: {_in: ["lens/@stani", "lens_id:0x024", "vitalik.eth", "0xeaf55242a90bb3289dB8184772b0B98562053559"]}}, blockchain: ALL, limit: 200}
) {
Following {
followingAddress {
addresses
domains { # Show all domains owned by followers
name
isPrimary
}
socials(input: { filter : { dappName : { _eq : farcaster}}}) {
profileName
profileTokenId
profileTokenIdHex
}
}
followingProfileId
followingTokenId
followerAddress {
addresses
domains {
name
}
socials(input: { filter : { dappName : { _eq : farcaster}}}) {
profileName
profileTokenId
profileTokenIdHex
}
}
followingProfileId
}
}
}
You can use the followerAddress.domains
that will return an array to see if there's any domain owned by the follower.
If the length of the followerAddress.domains
array is non-zero, then the follower has at least one ENS domain. Otherwise, it does not have any ENS domain.
Get Farcaster Users that have a certain amount of Following
You can get the list of Farcaster users that have a certain amount of following, e.g. at least 1000 following:
Try Demo
Code
Query Response
Copy query MyQuery {
Socials(
input: {
filter : { followingCount : { _gte : 1000 }, dappName : { _eq : farcaster } }
blockchain : ethereum
limit : 200
}
) {
Social {
profileName
userId
userAssociatedAddresses
followingCount
}
}
}
Copy {
"data" : {
"Socials" : {
"Social" : [
{
"profileName" : "jayme" ,
"userId" : "373" ,
"userAssociatedAddresses" : [
"0x1ca66c990e86b750ea6b2180d17fff89273a5c0d" ,
"0x9eab9d856a3a667dc4cd10001d59c679c64756e7"
] ,
"followingCount" : 1443
} ,
{
"profileName" : "aydasayer" ,
"userId" : "14993" ,
"userAssociatedAddresses" : [
"0xf009162e2495dd1dd54b5470e03004010f931a9f" ,
"0x022fe87e83f3d6662862ed51ef74de33ed16ff25"
] ,
"followingCount" : 1245
} ,
{
"profileName" : "reiri" ,
"userId" : "17626" ,
"userAssociatedAddresses" : [
"0x5f948ad313f280eb71d038f72d932f3b335458de" ,
"0x688d0cef9d2ad572e2b889ea595a042a1821e5ff"
] ,
"followingCount" : 1054
}
]
}
}
}
Developer Support
If you have any questions or need help regarding fetching Farcaster Followings data, please join our Airstack's Telegram group.
More Resources
Last updated 2 months ago