Skip to content

Latest commit

 

History

History
327 lines (247 loc) · 6.27 KB

social-followers.md

File metadata and controls

327 lines (247 loc) · 6.27 KB
description layout
Learn how fetch the social followers of a solana address on Farcaster.
title description tableOfContents outline pagination
visible
true
visible
true
visible
true
visible
visible
true

🫂 Social Followers

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:

{% tabs %} {% tab title="npm" %} React

npm install @airstack/airstack-react

Node

npm install @airstack/node

{% endtab %}

{% tab title="yarn" %} React

yarn add @airstack/airstack-react

Node

yarn add @airstack/node

{% endtab %}

{% tab title="pnpm" %} React

pnpm install @airstack/airstack-react

Node

pnpm install @airstack/node

{% endtab %}

{% tab title="pip" %}

pip install airstack

{% endtab %} {% endtabs %}

Then, add the following snippets to your code:

{% tabs %} {% tab title="React" %}

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>;
  }
};

{% endtab %}

{% tab title="Node" %}

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);

{% endtab %}

{% tab title="Python" %}

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())

{% endtab %} {% endtabs %}

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 Followers of Solana Address

You can get the list of Farcaster followers of a given solana address by using the SocialFollowers API:

Try Demo

{% embed url="https://app.airstack.xyz/query/E2h5mTEe8r" %} Show me all the social followers of GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV across Farcaster {% endembed %}

Code

{% tabs %} {% tab title="Query" %}

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        identity: { _eq: "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV" }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Follower {
      followerAddress {
        socials {
          dappName
          profileName
        }
      }
    }
  }
}

{% endtab %}

{% tab title="Response" %}

{
  "data": {
    "SocialFollowers": {
      "Follower": [
        {
          "followerAddress": {
            "socials": [
              {
                "dappName": "farcaster",
                "profileName": "ghostcode"
              }
            ]
          }
        },
        {
          "followerAddress": {
            "socials": [
              {
                "dappName": "farcaster",
                "profileName": "jackyang36"
              }
            ]
          }
        },
        {
          "followerAddress": {
            "socials": [
              {
                "dappName": "farcaster",
                "profileName": "saxenasaheb.eth"
              }
            ]
          }
        }
        // more followers on Farcaster
      ]
    }
  }
}

{% endtab %} {% endtabs %}

Check If Solana Address A Is Followed By Solana Address B

You can check if solana address A is followed by solana address B by using the Wallet API:

Try Demo

{% embed url="https://app.airstack.xyz/query/KP6G2gx9zl" %} Show me if solana address A is followed by solana address B {% endembed %}

Code

{% tabs %} {% tab title="Query" %}

query isFollowing {
  Wallet(
    input: {
      # Top-level is Solana address B
      identity: "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV",
      blockchain: ethereum
    }
  ) {
    socialFollowers( 
      input: {
        filter: {
          identity: {
            # Here is Solana address A
            _eq: "HyrNmmmce9W3rDdTQcZHyYvhuxPN6AaY3mVJcS9f4AZw"
          }
        }
      }
    ) {
      Follower {
        dappName
      }
    }
  }
}

{% endtab %}

{% tab title="Response" %}

{
  "data": {
    "Wallet": {
      "socialFollowers": {
        "Follower": [
          {
            // Solana address A is followed by Solana address B on Farcaster
            "dappName": "farcaster"
          }
        ]
      }
    }
  }
}

{% endtab %} {% endtabs %}

Developer Support

If you have any questions or need help regarding fetching social followers of a solana address, please join our Airstack's Telegram group.

More Resources