👭 Follows In CommonLearn 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
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.
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 0x address , ENS domain, Farcaster Name , 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 Response
Copy 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
}
}
}
}
}
}
}
}
Copy {
"data" : {
"SocialFollowers" : {
"Follower" : [
{
"followerAddress" : {
"socialFollowers" : {
"Follower" : [
{
"followerAddress" : {
"socials" : [
{
"fnames" : [
"prab.eth" ,
"prabh.eth" ,
"prab"
] ,
"profileName" : "prabh.eth" , // Follow both betashop.eth and ipeciura
"userId" : "11946" ,
"userAssociatedAddresses" : [
"0x8c34ae28c1bb84785e4c059c301842b7be295a01" ,
"0x3570958b8dcbc4f663f508efcedb454ee9af9516" ,
"0x44f9047ec33dd3682df5e9178c492272a5f7afd0" ,
"0x71167f1794c90510671f3d122207696709ef4417"
]
}
]
}
}
]
}
}
} ,
{
"followerAddress" : {
"socialFollowers" : {
"Follower" : [] // Follow betashop.eth, but doesn't follow ipeciura
}
}
}
]
}
}
}
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 0x address , ENS domain, Farcaster Name , or Farcaster ID .
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 Response
Copy 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
}
}
}
}
}
}
}
}
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
}
}
}
]
}
}
}
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 0x address , ENS domain, Farcaster Name , or Farcaster ID .
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 Response
Copy 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
}
}
}
}
}
}
}
}
Copy {
"data" : {
"SocialFollowers" : {
"Follower" : [
{
"followerAddress" : {
"socialFollowings" : {
"Following" : [
{
"followingAddress" : {
"socials" : [
{
"fnames" : [
"rish"
] ,
"profileName" : "rish" , // Follow betashop.eth and is followed by ipeciura
"userId" : "194" ,
"userAssociatedAddresses" : [
"0xb43a7cc909d842721c288ff90b03e511a78a4a8d" ,
"0xe9e261852ea62150eee685807df8fe3f211310a0" ,
"0x5a927ac639636e534b678e81768ca19e2c6280b7"
]
}
]
}
}
]
}
}
} ,
{
"followerAddress" : {
"socialFollowings" : {
"Following" : [] // follows betashop.eth, but isn't followed by ipeciura
}
}
}
]
}
}
}
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 0x address , ENS domain, Farcaster Name , or Farcaster ID .
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 Response
Copy 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
}
}
}
}
}
}
}
}
Copy {
"data" : {
"SocialFollowings" : {
"Following" : [
{
"followingAddress" : {
"socialFollowers" : {
"Follower" : [
{
"followerAddress" : {
"socials" : [
{
"fnames" : [ "vishwa" ] ,
"profileName" : "vishwa" , // is followed by betashop.eth and follows by ipeciura
"userId" : "7701" ,
"userAssociatedAddresses" : [
"0xe124b0590daa563746d86e3a810545c0e798136a" ,
"0x090f9b693b6b6d8213bc463235bddc65553c078f"
]
}
]
}
}
]
}
}
} ,
{
"followingAddress" : {
"socialFollowers" : {
"Follower" : [] // is followed by betashop.eth, but doesn't follow ipeciura
}
}
}
]
}
}
}
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 Response
Copy 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
}
}
}
}
}
}
}
}
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 Farcaster followers and followings in common, please join our Airstack's Telegram group.
More Resources
Last updated 6 months ago