đŸ–ŧī¸Farcaster Frames

Learn how to fetch Farcaster Frames data using the Airstack API and its various use cases and combinations.

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 The Frames Casted Within Certain Period Of Time

You can fetch all the frames casted within certain period of time by using the FarcasterCasts API and specify the time period in the castedAtTimestamp filter:

Try Demo

Show me all Farcaster Frames casted since Jan 1, 2024

Code

query MyQuery {
  FarcasterCasts(
    input: {
      filter: {
        castedAtTimestamp: {_gte: "2024-01-01T00:00:00Z"},
        hasFrames: {_eq: true}
      },
      blockchain: ALL
    }
  ) {
    Cast {
      castedBy {
        profileName
        fid: userId
      }
      frame {
        buttons {
          action
          id
          index
          target
        }
        castedAtTimestamp
        frameUrl
        imageAspectRatio
        imageUrl
        inputText
        postUrl
        state
      }
    }
  }
}

Get All The Frames Casted By Certain User

You can fetch all the frames casted by a certain Farcaster user by using the FarcasterCasts API and specify the caster's fname or fid in the castedBy filter:

Try Demo

Show me all Farcaster Frames casted by Farcaster user betashop.eth

Code

query MyQuery {
  FarcasterCasts(
    input: {
      filter: {
        castedBy: {_eq: "fc_fname:betashop.eth"},
        hasFrames: {_eq: true}
      },
      blockchain: ALL
    }
  ) {
    Cast {
      castedBy {
        profileName
        fid: userId
      }
      frame {
        buttons {
          action
          id
          index
          target
        }
        castedAtTimestamp
        frameUrl
        imageAspectRatio
        imageUrl
        inputText
        postUrl
        state
      }
    }
  }
}

Get All the Casts That Contains Certain Frame

You can fetch all the casts that contains a given Frame by using the FarcasterCasts API and specify the Farcaster Frame's URL in the frameUrl filter:

Try Demo

Show me all the casts that contains Frame URL https://frames.airstack.xyz/tt

Code

query MyQuery {
  FarcasterCasts(
    input: {
      filter: {
        frameUrl: {_eq: "https://frames.airstack.xyz/tt"}
      },
      blockchain: ALL
    }
  ) {
    Cast {
      castedBy {
        profileName
        fid: userId
      }
      text
      embeds
      mentions {
        fid
        position
      }
      numberOfLikes
      numberOfRecasts
      numberOfReplies
    }
  }
}

Get Details Of A Certain Farcaster Frames

You can fetch all the details of a given Frame by using the FarcasterCasts API and specify the Farcaster Frame's URL in the frameUrl filter:

Try Demo

Show me Frame details of Frame URL https://frames.airstack.xyz/tt

Code

query MyQuery {
  FarcasterCasts(
    input: {
      filter: {
        frameUrl: {_eq: "https://frames.airstack.xyz/tt"}
      },
      blockchain: ALL,
      limit: 1
    }
  ) {
    Cast {
      frame {
        buttons {
          action
          id
          index
          target
        }
        frameUrl
        imageAspectRatio
        imageUrl
        inputText
        postUrl
        state
      }
    }
  }
}

Developer Support

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

More Resources

Last updated

Was this helpful?