πŸ«‚Social Capital

Learn how to fetch Social Capital Scores and Ranks of Farcaster users, and how to fetch Social Capital Values of Farcaster casts.

Table Of Contents

In this guide you will learn how to use Airstack to:

Social Capital Scores

  • Social Capital Scores (SCS) are a measure of each Farcaster user's influence in the network.

    • This score is derived from a variety of onchain criteria (including Farcaster Hubs). Users with higher SCSs have more positive downstream influence, as their actions and engagements tends to result in higher quality overall engagement.

    • User's rank for their SCS is represented by Social Capital Rank (SCR).

    • Currently, the SCS is powered by a proprietary algorithm from Airstack. This algorithm is kept confidential to prevent manipulation.

    • Over time, we aim to refine the SCS based on its performance and eventually release it as an open-source protocol.

Social Capital Value

  • Social Capital Value (SCV) is a metric developed by Airstack to identify high-quality Trending Casts on Farcaster.

  • The SCS of a user impacts the SCV of a cast when the user engages with it. The type of engagement also plays a role. The accumulated SCS of all interactions contributes to the cast's overall SCV. Casts are then ranked by their SCV, promoting higher-quality casts.

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 A Farcaster User's Social Capital Score

You can use Socials API to fetch a Farcaster user's social capital score by providing the Farcaster user's fname or fid (check here for identity formats) to the identity input:

Try Demo

Show me social capital score of FID 602

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        dappName: {
          _eq: farcaster
        },
        identity: { _eq: "fc_fid:602" }
      },
      blockchain: ethereum
    }
  ) {
    Social {
      socialCapital {
        socialCapitalScoreRaw
        socialCapitalScore
      }
    }
  }
}

Get A Farcaster User's Social Capital Rank

Get Farcaster User's Social Capital Rank

You can use Socials API to fetch a Farcaster user's social capital rank by providing the Farcaster user's fname or fid (check here for identity formats) to the identity input:

Try Demo

Show me social capital rank of FID 602

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        dappName: {
          _eq: farcaster
        },
        identity: { _eq: "fc_fid:602" }
      },
      blockchain: ethereum
    }
  ) {
    Social {
      socialCapital {
        socialCapitalRank
      }
    }
  }
}

Get All Farcaster Users Sorted By Social Capital Scores

Get Farcaster Users Sorted By Social Capital Scores

You can use the Socials API to fetch all Farcaster users sorted by social capital scores by adding socialCapitalScore to the order field and set it to DESC value to sort in descending order:

Try Demo

Show me all Farcaster users sorted by social capital scores

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        dappName: {_eq: farcaster}
      },
      blockchain: ethereum,
      order: {socialCapitalScore: DESC}, # Add this to sort by SCS
      limit: 200
    }
  ) {
    Social {
      profileName
      fid: userId
      custodyAddress: userAddress
      connectedAddresses {
        address
        blockchain
      }
      socialCapital {
        socialCapitalScore
      }
    }
  }
}

Get All Farcaster Users With Social Capital Scores > X

You can use the Socials API to fetch all Farcaster users with social capital scores above certain number by using the socialCapitalScore input field and provide the X value to the _gt filter (for other comparators, check out here).

In the example below, X is 50:

If you would like to also sort the result by social capital score, simply add socialCapitalScore to the order field and set the value to DESC. To learn more how to do it, click here.

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        dappName: {_eq: farcaster},
        socialCapitalScore: {_gt: 50} # greater than to 50
      },
      blockchain: ethereum,
      limit: 200
    }
  ) {
    Social {
      profileName
      fid: userId
      custodyAddress: userAddress
      connectedAddresses {
        address
        blockchain
      }
      socialCapital {
        socialCapitalScore
      }
    }
  }
}

Get All Farcaster Users Sorted By Social Capital Rank

You can use the Socials API to fetch all Farcaster users sorted by social capital rank by adding socialCapitalRank to the order field and set it to ASC value to sort in ascending order:

Try Demo

Show me all Farcaster users sorted by social capital rank

Code

query MyQuery {
  Socials(
    input: {
      # Order by social capital rank in ascending order
      order: {socialCapitalRank: ASC},
      filter: {
        dappName: {
          _eq: farcaster
        }
      },
      blockchain: ethereum
    }
  ) {
    Social {
      profileName
      fid: userId
      custodyAddress: userAddress
      connectedAddresses {
        address
        blockchain
      }
      socialCapital {
        socialCapitalRank
      }
    }
  }
}

Get All Farcaster Users With Social Capital Rank < X

Get Farcaster Users With Social Capital Rank < X

You can use the Socials API to fetch all Farcaster users with social capital rank below certain value by using the socialCapitalRank input field and the _lte operator. If you prefer other comparator for your logic, you can use other available comparator that suits you need (check more here).

If you would like to also sort the result by social capital rank, simply add socialCapitalRank to the order field and set the value to ASC. To learn more how to do it, click here.

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        dappName: {
          _eq: farcaster
        },
        socialCapitalRank: {
          _lte: 100 # less than or equal to 100
        }
      },
      blockchain: ethereum
    }
  ) {
    Social {
      profileName
      fid: userId
      custodyAddress: userAddress
      connectedAddresses {
        address
        blockchain
      }
      socialCapital {
        socialCapitalRank
      }
    }
  }
}

Get A Farcaster Casts's Social Capital Value

You can use FarcasterCasts API to fetch a Farcaster cast's social capital value by providing the Warpcast URL to the url input:

Alternatively, you can also use the hash input filter and provide the cast hash if you have the cast hash value.

Try Demo

Code

query MyQuery {
  FarcasterCasts(
    input: {
      filter: {
        url: {_eq: "https://warpcast.com/dannylove/0xabc68559"}
      },
      blockchain: ALL
    }
  ) {
    Cast {
      socialCapitalValue {
        rawValue
        formattedValue
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching Social Capital data, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?