πŸŒ€Farcaster Recasts

Learn how to use the Airstack API to fetch Farcaster recasts and quoted recasts either from a certain user or a specific cast hash.

Farcaster Recasts Tutorial

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 Recasts By A Farcaster User

Farcaster Quoted Recasts Tutorial

You can use FarcasterReactions API to fetch all recasts by a Farcaster user by specifying the user's identity in reactedBy input filter:

If you are looking for quoted recasts, check this query instead.

Try Demo

Show me all recasts by FID 602

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: recasted,
        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 Recasted By A User In A Certain Channel

You can use the FarcasterReactions API to get all the casts recasted 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

Show me all the cast in /airstack channel recasted by FID 602

Code

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

Get All Quoted Recasts By A Farcaster User

You can use FarcasterQuotedRecasts API to fetch all quoted recasts by a Farcaster user by specifying the user's identity in recastedBy input filter:

Try Demo

Show me all quoted recasts by FID 602

Code

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

Get All Users That Recasts A Certain Cast

You can use FarcasterReactions API to get all the users that recasted a specific cast hash by providing the cast hash into castHash input filter:

Try Demo

Show me all users that recasts cast hash 0x4d5f904518bb9e8368eb560d1b93c762f7267cb4

Code

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

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

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

Try Demo

Show me all users that recasts any casts with Frames URL https://gallery.manifold.xyz/venicebreeze

Code

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

Get All Quoted Recasts From A Cast Casted By A Farcaster User

You can use FarcasterQuotedRecasts API to get all quoted recasts of any casts by a specified Farcaster user by providing the Farcaster user's identity to the parentCastedBy input filter:

Try Demo

Show me all quoted recasts from any casts by FID 602

Code

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

Check If A User Recasted A Certain Cast By Cast Hash

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

Try Demo

Check If FID 602 recasted cast hash 0x4d5f904518bb9e8368eb560d1b93c762f7267cb4

Code

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

Check If User A Quote Recasted A Cast By User B

You can FarcasterQuotedRecasts API to check if user A quote recasted any cast by user B:

Try Demo

Check If FID 2602 ever quoted recasts any of FID 602's cast

Code

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

Check If A User Recasted Any Cast In A Channel

You can use the FarcasterReactions APi to check if a user recasted 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

Check If FID 602 recasted any cast in /airstack channel

Code

query MyQuery {
  FarcasterReactions(
    input: {
      filter: {
        criteria: recasted,
        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 recasts data, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?