Onchain Data đ Social Followsđ Follows In CommonLearn 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
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Then, add the following snippets to your code:
React Node Python
Copy 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>;
}
};
Copy import { init, fetchQuery } from "@airstack/node";
init("YOUR_AIRSTACK_API_KEY");
const query = `YOUR_QUERY`; // Replace with GraphQL Query
const { data, error } = await fetchQuery(query);
console.log("data:", data);
console.log("error:", error);
Copy import asyncio
from airstack.execute_query import AirstackClient
api_client = AirstackClient(api_key="YOUR_AIRSTACK_API_KEY")
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main():
execute_query_client = api_client.create_execute_query_object(
query=query)
query_response = await execute_query_client.execute_query()
print(query_response.data)
asyncio.run(main())
Other Programming Languages
To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
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
Code
Query Response
Copy 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
}
}
}
}
}
}
}
}
Copy {
"data": {
"SocialFollowers": {
"Follower": [
{
"followerAddress": {
"socialFollowers": {
"Follower": [
{
"followerAddress": {
"socials": [
// follow both betashop.eth and ipeciura.eth
{
"fnames": [
"prab.eth",
"prabh.eth",
"prab"
],
"profileName": "prabh.eth",
"profileTokenId": "11946",
"profileTokenIdHex": "0x02eaa",
"userId": "11946",
"userAssociatedAddresses": [
"0x8c34ae28c1bb84785e4c059c301842b7be295a01",
"0x3570958b8dcbc4f663f508efcedb454ee9af9516",
"0x44f9047ec33dd3682df5e9178c492272a5f7afd0",
"0x71167f1794c90510671f3d122207696709ef4417"
]
},
{
"fnames": null,
"profileName": "lens/@retroflex",
"profileTokenId": "106741",
"profileTokenIdHex": "0x01a0f5",
"userId": "0x44f9047ec33dd3682df5e9178c492272a5f7afd0",
"userAssociatedAddresses": [
"0x44f9047ec33dd3682df5e9178c492272a5f7afd0"
]
}
]
}
}
]
}
}
},
{
"followerAddress": {
"socialFollowers": {
"Follower": [] // Follow betashop.eth, but doesn't follow ipeciura.eth
}
}
}
]
}
}
}
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
Code
Query Response
Copy 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
}
}
}
}
}
}
}
}
Copy {
"data": {
"SocialFollowings": {
"Following": [
{
"followingAddress": {
"socialFollowings": {
"Following": [
{
"followingAddress": {
"socials": [
{
"fnames": [
"nickcherry"
],
"profileName": "nickcherry", // is followed by betashop.eth and ipeciura
"userId": "145",
"userAssociatedAddresses": [
"0x1692101d7b84bf8ed8d828e44e55a8ca9a242bc4",
"0x3a8a1f045cd4f7246c6b3a78861269cc6065433a"
]
}
]
}
}
]
}
}
},
{
"followingAddress": {
"socialFollowings": {
"Following": [] // Followed by betashop.eth, but isn't followed by ipeciura
}
}
}
]
}
}
}
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
Code
Query Response
Copy 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
}
}
}
}
}
}
}
}
Copy {
"data": {
"SocialFollowers": {
"Follower": [
{
"followerAddress": {
"socialFollowings": {
"Following": [
{
"followingAddress": {
"socials": [
// Follower of betashop.eth and is followed by ipeciura.eth
{
"fnames": [
"rish"
],
"profileName": "rish",
"profileTokenId": "194",
"profileTokenIdHex": "0x0c2",
"userId": "194",
"userAssociatedAddresses": [
"0xb43a7cc909d842721c288ff90b03e511a78a4a8d",
"0xe9e261852ea62150eee685807df8fe3f211310a0",
"0x5a927ac639636e534b678e81768ca19e2c6280b7"
]
},
{
"fnames": null,
"profileName": "lens/@rishm",
"profileTokenId": "117299",
"profileTokenIdHex": "0x01ca33",
"userId": "0x5a927ac639636e534b678e81768ca19e2c6280b7",
"userAssociatedAddresses": [
"0x5a927ac639636e534b678e81768ca19e2c6280b7"
]
},
{
"fnames": null,
"profileName": "lens/@rishavmukherji",
"profileTokenId": "106198",
"profileTokenIdHex": "0x019ed6",
"userId": "0x5a927ac639636e534b678e81768ca19e2c6280b7",
"userAssociatedAddresses": [
"0x5a927ac639636e534b678e81768ca19e2c6280b7"
]
}
]
}
}
]
}
}
},
{
"followerAddress": {
"socialFollowings": {
"Following": [] // follower of betashop, but isn't followed by ipeciura.eth
}
}
}
]
}
}
}
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
Code
Query Response
Copy 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
}
}
}
}
}
}
}
}
Copy {
"data": {
"SocialFollowings": {
"Following": [
{
"followingAddress": {
"socialFollowers": {
"Follower": [
{
"followerAddress": {
"socials": [
// is followed by betashop.eth and follows ipeciura.eth
{
"fnames": null,
"profileName": "lens/@vishwa",
"profileTokenId": "100439",
"profileTokenIdHex": "0x018857",
"userId": "0x090f9b693b6b6d8213bc463235bddc65553c078f",
"userAssociatedAddresses": [
"0x090f9b693b6b6d8213bc463235bddc65553c078f"
]
},
{
"fnames": [
"vishwa"
],
"profileName": "vishwa",
"profileTokenId": "7701",
"profileTokenIdHex": "0x01e15",
"userId": "7701",
"userAssociatedAddresses": [
"0xe124b0590daa563746d86e3a810545c0e798136a",
"0x090f9b693b6b6d8213bc463235bddc65553c078f"
]
}
]
}
}
]
}
}
},
{
"followingAddress": {
"socialFollowers": {
"Follower": [] // is followed by betashop.eth, but does not follow ipeciura.eth
}
}
}
]
}
}
}
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
Code
Query Response
Copy 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
}
}
}
}
}
}
}
}
Copy {
"data": {
"SocialFollowers": {
"Follower": [
{
"followerAddress": {
"socialFollowings": {
"Following": [
{
"followingAddress": {
"socials": [
{
"fnames": [
"asiablockchain.eth",
"hosein778"
],
"profileName": "asiablockchain.eth", // mutually follows betashop.eth
"profileTokenId": "13752",
"profileTokenIdHex": "0x035b8",
"userId": "13752",
"userAssociatedAddresses": [
"0x5732411028f058a1c43e20c8e22a7a8cffbc04df",
"0xd78485a59e9763869bf1ec62c4520695bc826edc"
]
}
]
}
}
]
}
}
},
{
"followerAddress": {
"socialFollowings": {
"Following": [] // follow betashop.eth, but is not followed back by betashop.eth
}
}
}
]
}
}
}
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 5 months ago