👭Follows In Common

Learn how to fetch web3 social followers and followings in common between multiple users.

Airstack provides easy-to-use APIs for enriching Web3 social applications with and integrating on-chain and off-chain data with Lens and 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.

🤖 AI Natural Language​

Airstack 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.

Common Followers of Multiple User(s)

You can get the list of common followers of multiple users by providing either 0x addresses, ENS names, Lens profiles, or Farcasters:

Try Demo

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

Code

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

Common Following of Multiple User(s)

You can get the list of common following of multiple users by providing either 0x addresses, ENS names, Lens profiles, or Farcasters:

Try Demo

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

Code

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

Followers of User X That Also Following User Y

You can get the list of followers of user X, e.g. betashop.eth, that also is followed by user Y, e.g. ipeciura.eth, by providing either 0x addresses, ENS names, Lens profiles, or Farcasters:

Try Demo

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

Code

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

Following of User X That Also Follows User Y

You can get the list of following of user X, e.g. betashop.eth, that also follows user Y, e.g. ipeciura.eth, by providing either 0x addresses, ENS names, Lens profiles, or Farcasters:

Try Demo

Show me following of betashop.eth that also follows ipeciura.eth

Code

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

Mutual Follows of A User

You can get the mutual follows of a user using the same query as Followers of User X That Also Following User Y, where in this case X is equals to Y, e.g. betashop.eth:

Try Demo

Show me mutual follows of betashop.eth

Code

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

Developer Support

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

More Resources

Last updated

Was this helpful?