💐Farcaster Following

Learn 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

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

You can get the list of Farcaster following of Farcaster user(s) by inputting , ENS domain, , or Farcaster ID:

Try Demo

Code

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
    }
  }
}

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 , ENS domain, , or Farcaster ID:

Try Demo

Code

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 , ENS domain, , or Farcaster ID:

Try Demo

Code

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 , ENS domain, , or Farcaster ID:

Try Demo

Code

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 MyQuery {
  Socials(
    input: {
      filter: { followingCount: { _gte: 1000 }, dappName: { _eq: farcaster } }
      blockchain: ethereum
      limit: 200
    }
  ) {
    Social {
      profileName
      userId
      userAssociatedAddresses
      followingCount
    }
  }
}

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

Was this helpful?