πŸŸͺCertain Farcaster User

Learn how to use Airstack to show Trending Casts of a specific user FID on Farcaster based on various engagement criteria.

Criteria

Airstack provides multiple ways to fetch Trending Casts of a specific user FID:

NameValueDescription

criteria

social_capital_value |

likes | recasts | replies | likes_recasts_replies |

This will calculate and sort the Farcaster casts based on the chosen criteria: - social_capital_value(Recommended): the social capital value associated with the cast - likes: number of likes on the cast - recasts: number of recasts on the cast - replies: number of replies on the cast - likes_recasts_replies: number of total likes, recasts, and replies on the cast combined

fid

Int

Specify the FID of the Farcaster user for whom you wish to retrieve the trending cast from.

timeFrame

one_hour | two_hours | four_hours | eight_hours | twelve_hours | one_day | two_days | seven_days

Only fetch trending casts that have the most engagement within the chosen time frame, e.g. one_hour will fetch trending Farcaster casts with the most engagement for the last 1 hour.

Social Capital Value & Social Capital Scores

A new metric, Social Capital Value (SCV), has been introduced to identify high-quality trending broadcasts. SCV incorporates the authority of users, measured by another metric, Social Capital Scores (SCS), who engage with the broadcast based on on-chain data.

For additional information on SCV and SCS, please refer to the following section here.

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.

Once you have the criteria, fid, and timeFrame parameters prepared, simply use the query below and add the parameters as variables:

Try Demo

Code

query MyQuery(
  $criteria: TrendingCastsCriteria!,
  $timeFrame: TrendingCastTimeFrame!,
  $fid: Int!
) {
  TrendingCasts(
    input: {
      blockchain: ALL,
      criteria: $criteria,
      timeFrame: $timeFrame,
      filter: {
        fid: { _eq: $fid }
      }
    }
  ) {
    TrendingCast {
      criteria
      criteriaCount
      hash
      id
      socialCapitalValueFormatted
      socialCapitalValueRaw
      timeFrom
      timeTo
      cast {
        text
        mentions {
          fid
          position
        }
        embeds
        url
      }
    }
  }
}

πŸŽ‰ πŸ₯³ Congratulations you've just fetched all the trending Farcaster casts of a certain Farcaster user and integrate it into your application!

Developer Support

If you have any questions or need help regarding integrating or building trending casts of a certain user into your application, please join our Airstack's Telegram group.

More Resources

Last updated