πŸ”‚Farcaster Replies

Learn how to use the Airstack API to fetch Farcaster replies 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 Replies By A Farcaster User

You can use FarcasterReplies API to fetch all the replies casted by a given Farcaster user by specifying the user's identity in repliedBy input filter:

Try Demo

Code

query MyQuery {
  FarcasterReplies(
    input: {
      filter: {
        repliedBy: {_eq: "fc_fid:602"} # specify FID 602
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reply {
      castedAtTimestamp
      embeds
      url
      text
      numberOfRecasts
      numberOfLikes
      channel {
        channelId
      }
      mentions {
        fid
        position
      }
    }
  }
}

Get All Casts Replied By A User In A Certain Channel

You can use the FarcasterReactions API to get all the casts replied 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: replied,
        channelId: {_eq: "airstack"},
        reactedBy: {_eq: "fc_fid:602"}
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reaction {
      castHash
      cast {
        text
      }
    }
  }
}

Get All Replies Of A Certain Cast By Cast Hash

You can use FarcasterReplies API to fetch all replies of a given cast by specifying the cast hash in parentHash input filter:

Try Demo

Code

query MyQuery {
  FarcasterReplies(
    input: {
      filter: {
        parentHash: {_eq: "0x4c0f2172836b14a57d35f5d096ced49049b1d92d"}
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reply {
      fid
      castedAtTimestamp
      embeds
      url
      text
      numberOfRecasts
      numberOfLikes
      channel {
        channelId
      }
      mentions {
        fid
        position
      }
    }
  }
}

Get All Replies From A Cast Casted By A Farcaster User

You can use FarcasterReplies API to fetch all the replies from any casts casted by a given Farcaster user by specifying the user's identity in parentCastedBy input filter:

Try Demo

Code

query MyQuery {
  FarcasterReplies(
    input: {
      filter: {
        parentCastedBy: {_eq: "fc_fid:602"}
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reply {
      fid
      castedAtTimestamp
      embeds
      url
      text
      numberOfRecasts
      numberOfLikes
      channel {
        channelId
      }
      mentions {
        fid
        position
      }
    }
  }
}

Get All Replies From All Casts That Contains Certain Farcaster Frames

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

Try Demo

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: replied,
        frameUrl: {_eq: "https://gallery.manifold.xyz/venicebreeze"}
      },
      blockchain: ALL,
      limit: 200
    }
  ) {
    Reaction {
      cast {
        castedAtTimestamp
        embeds
        url
        text
        numberOfRecasts
        numberOfLikes
        channel {
          channelId
        }
        mentions {
          fid
          position
        }
      }
    }
  }
}

Check If A User Replied A Certain Cast

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

Try Demo

Code

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

Check If User A Replied Any Cast By User B

You can use FarcasterReplies API to check if user A replied to any cast by user B:

Try Demo

Code

query MyQuery {
  FarcasterReplies(
    input: {
      filter: {
        repliedBy: {_eq: "fc_fid:2602"}, # user A
        parentCastedBy: {_eq: "fc_fid:602"} # user B
      },
      blockchain: ALL,
      limit: 1
    }
  ) {
    Reply {
      castedAtTimestamp
    }
  }
}

Check If A User Replied Any Cast In A Channel

You can use the FarcasterReactions APi to check if a user replied 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: replied,
        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 replies data, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?