đŧī¸ Farcaster FramesLearn 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
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Then, add the following snippets to your code:
React Node Python
Copy 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 >;
}
};
Copy import { init , fetchQuery } from "@airstack/node" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const { data , error } = await fetchQuery (query);
console .log ( "data:" , data);
console .log ( "error:" , error);
Copy import asyncio
from airstack . execute_query import AirstackClient
api_client = AirstackClient (api_key = "YOUR_AIRSTACK_API_KEY" )
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main ():
execute_query_client = api_client . create_execute_query_object (
query = query)
query_response = await execute_query_client . execute_query ()
print (query_response.data)
asyncio . run ( main ())
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
Code
Query Response
Copy 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
}
}
}
}
Copy {
"data" : {
"FarcasterCasts" : {
"Cast" : [
{
"castedBy" : {
"profileName" : "kregitmhun" ,
"fid" : "254808"
} ,
"frame" : {
"buttons" : [
{
"action" : "" ,
"id" : "0x85bffc4de32c70688855f31a868181613fe4182890c4d35224a0afa311cfc6df-1" ,
"index" : 1 ,
"target" : ""
}
] ,
"castedAtTimestamp" : "2024-02-27T19:07:24Z" ,
"frameUrl" : "https://api.anky.lat/farcaster-frames/newen-tldr" ,
"imageAspectRatio" : "" ,
"imageUrl" : "https://jpfraneto.github.io/images/newen2.png" ,
"inputText" : "" ,
"postUrl" : "http://api.anky.lat/farcaster-frames/newen-tldr?page=1" ,
"state" : ""
}
} ,
// Other Frames casted since Jan 1, 2024
]
}
}
}
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
Code
Query Response
Copy 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
}
}
}
}
Copy {
"data" : {
"FarcasterCasts" : {
"Cast" : [
{
"castedBy" : {
"profileName" : "betashop.eth" ,
"fid" : "602"
} ,
"frame" : {
"buttons" : [
{
"action" : "link" ,
"id" : "0x7ace9add807d8f0b393e50a20ac64d620d2faa0d766b06187a0f036978cb5dd5-2" ,
"index" : 2 ,
"target": "https://warpcast.com/~/compose?embeds%5B%5D=https%3A%2F%2Fframes.airstack.xyz%2Ftt&text=hihi%2C+see+what+tokens+are+trending+right+now+on+Farcaster"
} ,
{
"action" : "post" ,
"id" : "0x7ace9add807d8f0b393e50a20ac64d620d2faa0d766b06187a0f036978cb5dd5-4" ,
"index" : 4 ,
"target" : ""
} ,
{
"action" : "link" ,
"id" : "0x7ace9add807d8f0b393e50a20ac64d620d2faa0d766b06187a0f036978cb5dd5-3" ,
"index" : 3 ,
"target" : "https://www.airstack.xyz/leaderboard"
} ,
{
"action" : "post" ,
"id" : "0x7ace9add807d8f0b393e50a20ac64d620d2faa0d766b06187a0f036978cb5dd5-1" ,
"index" : 1 ,
"target" : "https://frames.airstack.xyz/tt/frame?a=1&b=4&c=1&t=4&r=2&f=1&info=1"
}
] ,
"castedAtTimestamp" : "2024-03-30T14:21:30Z" ,
"frameUrl" : "https://frames.airstack.xyz/tt" ,
"imageAspectRatio" : "1.91:1" ,
"imageUrl" : "https://frames.airstack.xyz/tt/image?a=1&b=4&c=1&t=4&r=2" ,
"inputText" : "" ,
"postUrl" : "https://frames.airstack.xyz/tt/frame?a=1&b=4&c=1&t=4&r=2" ,
"state" : ""
}
} ,
// Other Frames casted by betashop.eth
]
}
}
}
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
Code
Query Response
Copy 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
}
}
}
Copy {
"data" : {
"FarcasterCasts" : {
"Cast" : [
{
"castedBy" : {
"profileName" : "echovenus22" ,
"fid" : "260925"
} ,
"text" : "hihi, see what tokens are trending right now on Farcaster đ\n\nLet'sgooo joined to get points â¨" ,
"embeds" : [
{
"url" : "https://frames.airstack.xyz/tt"
}
] ,
"mentions" : [] ,
"numberOfLikes" : 0 ,
"numberOfRecasts" : 0 ,
"numberOfReplies" : 0
} ,
// Other casts by other users
]
}
}
}
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
Code
Query Response
Copy 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
}
}
}
}
Copy {
"data" : {
"FarcasterCasts" : {
"Cast" : [
{
"frame" : {
"buttons" : [
{
"action" : "link" ,
"id" : "0x7ace9add807d8f0b393e50a20ac64d620d2faa0d766b06187a0f036978cb5dd5-2" ,
"index" : 2 ,
"target": "https://warpcast.com/~/compose?embeds%5B%5D=https%3A%2F%2Fframes.airstack.xyz%2Ftt&text=hihi%2C+see+what+tokens+are+trending+right+now+on+Farcaster"
} ,
{
"action" : "post" ,
"id" : "0x7ace9add807d8f0b393e50a20ac64d620d2faa0d766b06187a0f036978cb5dd5-4" ,
"index" : 4 ,
"target" : ""
} ,
{
"action" : "post" ,
"id" : "0x7ace9add807d8f0b393e50a20ac64d620d2faa0d766b06187a0f036978cb5dd5-1" ,
"index" : 1 ,
"target" : "https://frames.airstack.xyz/tt/frame?a=1&b=4&c=1&t=4&r=2&f=1&info=1"
} ,
{
"action" : "link" ,
"id" : "0x7ace9add807d8f0b393e50a20ac64d620d2faa0d766b06187a0f036978cb5dd5-3" ,
"index" : 3 ,
"target" : "https://www.airstack.xyz/leaderboard"
}
] ,
"frameUrl" : "https://frames.airstack.xyz/tt" ,
"imageAspectRatio" : "1.91:1" ,
"imageUrl" : "https://frames.airstack.xyz/tt/image?a=1&b=4&c=1&t=4&r=2" ,
"inputText" : "" ,
"postUrl" : "https://frames.airstack.xyz/tt/frame?a=1&b=4&c=1&t=4&r=2" ,
"state" : ""
}
}
]
}
}
}
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 Response
Copy query MyQuery {
FarcasterReactions(
input: {
filter : {
criteria : recasted,
frameUrl : { _eq : "https://gallery.manifold.xyz/venicebreeze" }
},
blockchain : ALL,
limit : 200
}
) {
Reaction {
cast {
castedAtTimestamp
embeds
url
text
numberOfRecasts
numberOfLikes
channel {
channelId
}
mentions {
fid
position
}
}
}
}
}
Copy {
"data" : {
"FarcasterReactions" : {
"Reaction" : [
{
"cast" : {
"castedAtTimestamp" : "2024-05-06T17:32:10Z" ,
"embeds" : [
{
"url" : "https://cdn.botfrens.com/contents/2731379/web_md.jpg"
} ,
{
"url" : "https://gallery.manifold.xyz/venicebreeze"
}
] ,
"url" : "https://warpcast.com/carlos28355/0xf10f3c56" ,
"text" : "âī¸ Venice Breeze đģ\r\n1/1\r\nMinted & listed with Manifold " ,
"numberOfRecasts" : 4 ,
"numberOfLikes" : 16 ,
"channel" : {
"channelId" : "cryptoart"
} ,
"mentions" : []
}
} ,
// other replies
]
}
}
}
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 Response
Copy query MyQuery {
FarcasterReactions(
input: {
filter : {
criteria : recasted,
frameUrl : { _eq : "https://gallery.manifold.xyz/venicebreeze" }
},
blockchain : ALL,
limit : 200
}
) {
Reaction {
reactedBy {
profileName
fid : userId
}
}
}
}
Copy {
"data" : {
"FarcasterReactions" : {
"Reaction" : [
{
"reactedBy" : {
"profileName" : "matthewbian" ,
"fid" : "461708"
}
} ,
// Other users that recasts
]
}
}
}
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 Response
Copy query MyQuery {
FarcasterReactions(
input: {
filter : {
criteria : liked,
frameUrl : { _eq : "https://gallery.manifold.xyz/venicebreeze" }
},
blockchain : ALL,
limit : 200
}
) {
Reaction {
reactedBy {
profileName
fid : userId
}
}
}
}
Copy {
"data" : {
"FarcasterReactions" : {
"Reaction" : [
{
"reactedBy" : {
"profileName" : "matthewbian" ,
"fid" : "461708"
}
} ,
// Other users that likes
]
}
}
}
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 7 months ago