💐 Social FollowingsLearn how fetch the social followings of a solana address on 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.
Get All Followings of Solana Address
You can get the list of Farcaster followings of a given solana address by using the SocialFollowings
API:
Try Demo
Code
Query Response
Copy query MyQuery {
SocialFollowings(
input: {
filter : {
identity : { _eq : "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV" }
}
blockchain : ALL
limit : 200
}
) {
Following {
followingAddress {
socials {
dappName
profileName
}
}
}
}
}
Copy {
"data" : {
"SocialFollowings" : {
"Following" : [
{
"followingAddress" : {
"socials" : [
{
"dappName" : "farcaster" ,
"profileName" : "phabc"
}
]
}
} ,
{
"followingAddress" : {
"socials" : [
{
"dappName" : "farcaster" ,
"profileName" : "guapolocal.eth"
}
]
}
} ,
{
"followingAddress" : {
"socials" : [
{
"dappName" : "farcaster" ,
"profileName" : "ir"
}
]
}
} ,
{
"followingAddress" : {
"socials" : [
{
"dappName" : "farcaster" ,
"profileName" : "crick"
}
]
}
}
// more followings on Farcaster
]
}
}
}
Check If Solana Address A Is Following Solana Address B
You can check if solana address A is following solana address B by using the Wallet
API:
Try Demo
Code
Query Response
Copy query isFollowing {
Wallet(
input: {
# Top-level is Solana address B
identity : "HyrNmmmce9W3rDdTQcZHyYvhuxPN6AaY3mVJcS9f4AZw" ,
blockchain : ethereum
}
) {
socialFollowings(
input: {
filter : {
identity : {
# Here is Solana address A
_eq : "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV"
}
}
}
) {
Following {
dappName
}
}
}
}
Copy {
"data" : {
"Wallet" : {
"socialFollowings" : {
"Following" : [
{
// Solana address A is following solana address B on Farcaster
"dappName" : "farcaster"
}
]
}
}
}
}
Developer Support
If you have any questions or need help regarding fetching social followings of a solana address, please join our Airstack's Telegram group.
More Resources