👭Follows In Common

Learn how to fetch Farcaster users who are following or being followed by two Farcaster users.

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

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.

Farcaster Users Who Are Following Two Given Farcaster Users

You can get the list of Farcaster users which are following two given Farcaster users by inputting , ENS domain, , or Farcaster ID.

For example, get all Farcaster users which are following both Farcaster users fc_fname:betashop.eth and fc_fname:ipeciura:

Try Demo

Show me common followers of both fc_fname betashop.eth and fc_fname ipeciura

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        identity: { _eq: "fc_fname:betashop.eth" }
        dappName: { _eq: farcaster }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Follower {
      followerAddress {
        socialFollowers(
          input: {
            filter: {
              identity: { _eq: "fc_fname:ipeciura" }
              dappName: { _eq: farcaster }
            }
            limit: 200
          }
        ) {
          Follower {
            followerAddress {
              socials(input: { filter: { dappName: { _eq: farcaster } } }) {
                fnames
                profileName
                userId
                userAssociatedAddresses
              }
            }
          }
        }
      }
    }
  }
}

Farcaster Users Who Are Being Followed By Two Given Farcaster Users

You can get the list of all Farcaster users being followed by two given Farcaster users by inputting , ENS domain, , or .

For example, get all Farcaster users which are being followed by both Farcaster users fc_fname:betashop.eth and fc_fname:ipeciura:

Try Demo

Show me common following of both fc_fname betashop.eth and fc_fname ipeciura

Code

query MyQuery {
  SocialFollowings(
    input: {
      filter: {
        identity: { _eq: "fc_fname:betashop.eth" }
        dappName: { _eq: farcaster }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Following {
      followingAddress {
        socialFollowings(
          input: {
            filter: {
              identity: { _eq: "fc_fname:ipeciura" }
              dappName: { _eq: farcaster }
            }
            limit: 200
          }
        ) {
          Following {
            followingAddress {
              socials(input: { filter: { dappName: { _eq: farcaster } } }) {
                fnames
                profileName
                userId
                userAssociatedAddresses
              }
            }
          }
        }
      }
    }
  }
}

Farcaster Users Who Are Following User X That Are Also Being Followed By User Y

You can get the list of Farcaster users that is following Farcaster user X who are also being followed by another Farcaster user Y by inputting , ENS domain, , or .

For example, get all Farcaster users that is following Farcaster user fc_fname:betashop.eth who are also being followed by fc_fname:ipeciura:

Try Demo

Show me followers of fc_fname betashop.eth that is also followed by fc_fname ipeciura

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        identity: { _eq: "fc_fname:betashop.eth" }
        dappName: { _eq: farcaster }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Follower {
      followerAddress {
        socialFollowings(
          input: {
            filter: {
              identity: { _eq: "fc_fname:ipeciura" }
              dappName: { _eq: farcaster }
            }
            limit: 200
          }
        ) {
          Following {
            followingAddress {
              socials(input: { filter: { dappName: { _eq: farcaster } } }) {
                fnames
                profileName
                userId
                userAssociatedAddresses
              }
            }
          }
        }
      }
    }
  }
}

Farcaster Users Who Are Being Followed By User X That Are Also Following By User Y

You can get a list of Farcaster users who are being followed by Farcaster user X and also are following another Farcaster user Y by inputting , ENS domain, , or .

For example, get all Farcaster users who are being followed by fc_fname:betashop.eth and also are following fc_fname:ipeciura:

Try Demo

Show me following of fc_fname betashop.eth that is also followers of fc_fname ipeciura

Code

query MyQuery {
  SocialFollowings(
    input: {
      filter: {
        identity: { _eq: "fc_fname:betashop.eth" }
        dappName: { _eq: farcaster }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Following {
      followingAddress {
        socialFollowers(
          input: {
            filter: {
              identity: { _eq: "fc_fname:ipeciura" }
              dappName: { _eq: farcaster }
            }
            limit: 200
          }
        ) {
          Follower {
            followerAddress {
              socials(input: { filter: { dappName: { _eq: farcaster } } }) {
                fnames
                profileName
                userId
                userAssociatedAddresses
              }
            }
          }
        }
      }
    }
  }
}

Mutual Farcaster Follows of A Farcaster User

You can fetch all Farcaster users that are following a given Farcaster user X and check if Farcaster user X is mutually following back.

For example, get all Farcaster users that are following fc_fname:betashop.eth and check if fc_fname:betashop.eth is mutually following back:

Try Demo

Show me mutual Farcaster follows of fc_fname betashop.eth

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        identity: { _eq: "fc_fname:betashop.eth" }
        dappName: { _eq: farcaster }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Follower {
      followerAddress {
        socialFollowings(
          input: {
            filter: {
              identity: { _eq: "fc_fname:betashop.eth" }
              dappName: { _eq: farcaster }
            }
            limit: 200
          }
        ) {
          Following {
            followingAddress {
              socials(input: { filter: { dappName: { _eq: farcaster } } }) {
                fnames
                profileName
                userId
                userAssociatedAddresses
              }
            }
          }
        }
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching Farcaster followers and followings in common, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?