πŸ«‚Lens Followers

Learn how to fetch Lens followers data and its various use cases and combinations.

πŸ«‚ Lens Followers

Airstack provides easy-to-use APIs for enriching Lens applications and integrating on-chain and off-chain data with Lens.

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 Lens Followers of Lens Profile(s)

You can get the list of Lens followers of Lens profile(s) by inputting either their 0x address, or Lens profile ID ( or ):

Try Demo

Show me the Lens followers of lens/@stani, lens_id:0x024, vitalik.eth, 0xeaf55242a90bb3289dB8184772b0B98562053559

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        dappName: { _eq: lens }
        identity: {
          _in: [
            "lens/@stani"
            "lens_id:0x024"
            "vitalik.eth"
            "0xeaf55242a90bb3289dB8184772b0B98562053559"
          ]
        }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Follower {
      followerAddress {
        addresses
        socials(input: { filter: { dappName: { _eq: lens } } }) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
      }
      followerProfileId
      followerTokenId
      followingAddress {
        addresses
        domains {
          name
        }
        socials(input: { filter: { dappName: { _eq: lens } } }) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
      }
      followingProfileId
    }
  }
}

Check A Given Lens Profile is A Follower of User(s) on Lens

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

This can be done by providing the given Lens profile on the Wallet top-level query's identity input and the user(s) in the socialFollowers:

Try Demo

Show me if lens/@shnoodles is a follower of a group of users on Lens

Code

query isFollowing {
  Wallet(input: {identity: "lens/@shnoodles", blockchain: ethereum}) {
    socialFollowers( # Check if lens/@shnoodles 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: lens}}}
    ) {
      Follower {
        dappName
        dappSlug
        followingProfileId
        followerProfileId
        followingAddress {
          addresses
          socials {
            profileName
          }
          domains {
            name
          }
        }
      }
    }
  }
}

If lens/@shnoodles 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 The Most Recent Lens Followers of Lens Profile(s)

You can get the list of most recent Lens followers of Lens profile(s) by inputting either their 0x address, or Lens profile ID ( or ):

Try Demo

Show me the most recent Lens followers of lens/@stani, lens_id:0x024, vitalik.eth, 0xeaf55242a90bb3289dB8184772b0B98562053559

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        dappName: { _eq: lens }
        identity: {
          _in: [
            "lens/@stani"
            "lens_id:0x024"
            "vitalik.eth"
            "0xeaf55242a90bb3289dB8184772b0B98562053559"
          ]
        }
      }
      blockchain: ALL
      limit: 200
      order: { followerSince: DESC }
    }
  ) {
    Follower {
      followerAddress {
        addresses
        socials(input: { filter: { dappName: { _eq: lens } } }) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
      }
      followerProfileId
      followerTokenId
      followingAddress {
        addresses
        domains {
          name
        }
        socials(input: { filter: { dappName: { _eq: lens } } }) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
      }
      followingProfileId
    }
  }
}

Get The Earliest Lens Followers of Lens Profile(s)

You can get the list of the earliest Lens followers of Lens profile(s) by inputting either their 0x address, or Lens profile ID ( or ):

Try Demo

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        dappName: { _eq: lens }
        identity: {
          _in: [
            "lens/@stani"
            "lens_id:0x024"
            "vitalik.eth"
            "0xeaf55242a90bb3289dB8184772b0B98562053559"
          ]
        }
      }
      blockchain: ALL
      limit: 200
      order: { followerSince: ASC }
    }
  ) {
    Follower {
      followerAddress {
        addresses
        socials(input: { filter: { dappName: { _eq: lens } } }) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
      }
      followerProfileId
      followerTokenId
      followingAddress {
        addresses
        domains {
          name
        }
        socials(input: { filter: { dappName: { _eq: lens } } }) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
      }
      followingProfileId
    }
  }
}

Get Lens Followers of Lens Profile(s) that has ENS Domain

You can get the list of Lens followers of Lens profile(s) and check if they have any ENS domain by inputting either their 0x address, or Lens profile ID ( or ):

Try Demo

Code

query MyQuery {
  SocialFollowers(
    input: {filter: {dappName: {_eq: lens}, identity: {_in: ["lens/@stani", "lens_id:0x024", "vitalik.eth", "0xeaf55242a90bb3289dB8184772b0B98562053559"]}}, blockchain: ALL, limit: 200}
  ) {
    Follower {
      followerAddress {
        addresses
        domains { # Show all domains owned by followers
          name
          isPrimary
        }
        socials(input: {filter: {dappName: {_eq: lens}}}) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
      }
      followerProfileId
      followerTokenId
      followingAddress {
        addresses
        domains {
          name
        }
        socials(input: {filter: {dappName: {_eq: lens}}}) {
          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 Lens Followers of Lens Profile(s) that has XMTP Enabled

You can get the list of Lens followers of Lens profile(s) and check if they have XMTP enabled by inputting either their 0x address, or Lens profile ID ( or ):

Try Demo

Code

query MyQuery {
  SocialFollowers(
    input: {filter: {dappName: {_eq: lens}, identity: {_in: ["lens/@stani", "lens_id:0x024", "vitalik.eth", "0xeaf55242a90bb3289dB8184772b0B98562053559"]}}, blockchain: ALL, limit: 200}
  ) {
    Follower {
      followerAddress {
        addresses
        socials(input: {filter: {dappName: {_eq: lens}}}) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
        xmtp {
          isXMTPEnabled # Indicate if followers have XMTP enabled
        }
      }
      followerProfileId
      followerTokenId
      followingAddress {
        addresses
        domains {
          name
        }
        socials(input: {filter: {dappName: {_eq: lens}}}) {
          profileName
          profileTokenId
          profileTokenIdHex
        }
      }
      followingProfileId
    }
  }
}

You can use the followerAddress.xmtp.isXMTPEnabled field to check if the follower has XMTP enabled or not.

If followerAddress.xmtp.isXMTPEnabled field returns true, then the follower has XMTP enabled. Otherwise, it will return null and thus has not enabled XMTP.

Get Lens Profiles that have a certain amount of Followers

You can get all the Lens profiles that have a certain amount of followers, e.g. more than or equal to 1000 follower counts on Lens:

Try Demo

Code

query MyQuery {
  Socials(
    input: {filter: {followerCount: {_gte: 1000}, dappName: {_eq: lens}}, blockchain: ethereum, limit: 200}
  ) {
    Social {
      profileName
      profileTokenId
      profileTokenIdHex
      followerCount # Show the total follower count of each follower
    }
  }
}

To get the individual follower count of each Lens profile, use followerCount field that will return an integer type.

Get Lens and Farcaster Followers of Lens Profile(s)

You can get the list of Lens and Farcaster followers of Lens profile(s) by inputting either their 0x address, or Lens profile ID ( or ):

Try Demo

Code

query MyQuery {
  SocialFollowers(
    input: {
</