🌀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.

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

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

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 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

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

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

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

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

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

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
    }
  }
}

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?