πŸ‘Farcaster Likes

Learn how to use the Airstack API to fetch Farcaster likes reaction either from a certain user or a specific cast hash.

Table Of Contents

In this guide, you will learn 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:

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 All Casts Liked By A User

You can use the FarcasterReactions API to get all the casts liked by a user by providing the user's identity to reactedBy input filter:

Try Demo

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: liked,
        reactedBy: {_eq: "fc_fid:602"}
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reaction {
      cast {
        castedAtTimestamp
        embeds
        url
        text
        numberOfRecasts
        numberOfLikes
        channel {
          channelId
        }
        mentions {
          fid
          position
        }
      }
    }
  }
}

Get All Casts Liked By A User In A Certain Channel

You can use the FarcasterReactions API to get all the casts liked by a user in a certain channel by providing the user's identity to reactedBy and the channel ID to channelId input filter:

Try Demo

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: liked,
        channelId: {_eq: "airstack"},
        reactedBy: {_eq: "fc_fid:602"}
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reaction {
      castHash
      cast {
        text
      }
    }
  }
}

Get All Users That Like A Certain Cast

You can use the FarcasterReactions APi to get all the users that liked a cast by providing the cast hash to castHash input filter:

Try Demo

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: liked,
        castHash: {_eq: "0xfc328b9ba0a18fa271c508f9b91b0b66f23062fe"}
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reaction {
      reactedBy {
        profileName
        fid: userId
      }
    }
  }
}

Get All Users That Likes Any Casts That Contains A Certain Farcaster Frames

You can use FarcasterReactions API to fetch all users that likes all casts that contains a certain Frames by providing the Frames URL to the frameUrl input filter:

Try Demo

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: liked,
        frameUrl: {_eq: "https://gallery.manifold.xyz/venicebreeze"}
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reaction {
      reactedBy {
        profileName
        fid: userId
      }
    }
  }
}

Check If A User Like A Certain Cast

You can use the FarcasterReactions APi to check if a user like a certain cast by providing the cast hash to castHash and the user's identity to the reactedBy input filter:

Try Demo

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: liked,
        castHash: {_eq: "0xfc328b9ba0a18fa271c508f9b91b0b66f23062fe"},
        reactedBy: {_eq: "fc_fid:602"}
      },
      blockchain: ALL
    }
  ) {
    Reaction {
      castHash
    }
  }
}

Check If A User Liked Any Cast In A Channel

You can use the FarcasterReactions APi to check if a user like any cast in a certain channel by providing the channel ID to channelID and the user's identity to the reactedBy input filter:

Try Demo

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: liked,
        channelId: {_eq: "airstack"},
        reactedBy: {_eq: "fc_fid:602"}
      },
      blockchain: ALL,
      limit: 1
    }
  ) {
    Reaction {
      castHash
    }
  }
}

Developer Support

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

More Resources

Last updated

Was this helpful?