đŸĢ‚Farcaster Followers

Learn how to fetch Farcaster followers 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

  • An Airstack account

  • 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

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 (data) {
    return <p>Data: {JSON.stringify(data)}</p>;
  }

  if (loading) {
    return <p>Loading...</p>;
  }

  if (error) {
    return <p>Error: {error.message}</p>;
  }
};

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 Followers of Farcaster User(s)

You can get the list of Farcaster followers of Farcaster user(s) by inputting 0x address[^1], ENS domain, Farcaster Name[^2], or Farcaster ID:

Try Demo

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        dappName: { _eq: farcaster }
        identity: {
          _in: [
            "fc_fname:dwr.eth"
            "fc_fid:602"
            "varunsrin.eth"
            "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
          ]
        }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Follower {
      followerAddress {
        addresses
        socials(input: { filter: { dappName: { _eq: farcaster } } }) {
          profileName
          userId
          userAssociatedAddresses
        }
      }
      followerProfileId
      followerTokenId
      followingAddress {
        addresses
        domains {
          name
        }
        socials(input: { filter: { dappName: { _eq: farcaster } } }) {
          profileName
          userId
          userAssociatedAddresses
        }
      }
      followingProfileId
    }
  }
}

Check A Given Farcaster User is A Follower of User(s) on Farcaster

You can use Airstack to check if user(s) is following a given Farcaster user on Farcaster.

This can be done by providing the given Farcaster name[^3] or ID on the Wallet top-level query's identity input and the user(s) in the socialFollowers:

Try Demo

Code

query isFollowing {
  Wallet(input: {identity: "fc_fname:ipeciura.eth", blockchain: ethereum}) {
    socialFollowers( # Check if fc_fname:ipeciura.eth is a follower of these user identities on Lens
      input: {filter: {identity: {_in: ["0xeaf55242a90bb3289dB8184772b0B98562053559", "betashop.eth", "yosephks.cb.id", "lens/@deepesh", "lens_id:100275", "fc_fname:dawufi", "fc_fid:602"]}, dappName: {_eq: farcaster}}}
    ) {
      Follower {
        dappName
        dappSlug
        followingProfileId
        followerProfileId
        followingAddress {
          addresses
          socials {
            dappName
            profileName
          }
          domains {
            name
          }
        }
      }
    }
  }
}

If ipeciura.eth is a follower of any of the users on Lens, then it will appear as a response in the Follower array as shown in the sample response.

Get Farcaster Users that have a certain amount of Followers

You can get the list of all Farcaster users that have a certain amount of followers, e.g. at least 1000 followers:

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: { followerCount: { _gte: 1000 }, dappName: { _eq: farcaster } }
      blockchain: ethereum
      limit: 200
    }
  ) {
    Social {
      profileName
      userId
      userAssociatedAddresses
      followerCount
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching Farcaster Followers data, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?