To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
Get All Casts Casted In A Channel
You can fetch all the casts casted in a certain Farcaster channel by using the FarcasterCasts API and providing the Farcaster channel's URL to the channelUrl filter:
If you don't know the channel's URL, then find the channel's URL with this query here. The url field will return you the channel's URL associated with the given channel ID.
{
"data": {
"FarcasterCasts": {
"Cast": [
{
"castedAtTimestamp": "2024-05-15T10:42:06Z",
"castedBy": {
"profileName": "juampi",
"fid": "6730"
},
"embeds": [
{
"url": "https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/84b11c9b-2308-43c5-821b-b73d7687b400/original"
}
],
"fid": "6730",
"hash": "0xb2a16ed043b762e097627ed5b080d5c482b4664b",
"text": "Everyone loving the Airstack frame, super smooth experience!\n\nNow you can buy $BUILD on it đĢĄ",
"numberOfLikes": 3,
"numberOfRecasts": 0,
"numberOfReplies": 0
}
// More casts from /airstack channel
]
}
}
}
Get All Casts Casted By A Farcaster User
You can fetch all the casts casted by a Farcaster user by using the FarcasterCasts API and providing the Farcaster user's fname or fid to the castedBy filter:
You can fetch all the casts casted that contain Frames by using the FarcasterCasts API and providing the time period to the castedAtTimestamp filter with the appropriate operators:
Try Demo
Code
query MyQuery {
FarcasterCasts(
input: {
filter: {
# Make sure to set `castedTimestamp` with the matching operator
# to filter by the desired time period
castedAtTimestamp: {_gte: "2024-01-01T00:00:00Z"}
},
blockchain: ALL
}
) {
Cast {
castedAtTimestamp
embeds
url
text
numberOfRecasts
numberOfLikes
channel {
channelId
}
mentions {
fid
position
}
}
}
}
{
"data": {
"FarcasterCasts": {
"Cast": [
{
"castedAtTimestamp": "2024-02-27T19:07:28Z",
"embeds": [],
"url": "https://warpcast.com/qdau.eth/0x654ed051",
"text": "not siue if that's a warpcast or zora problem, but mint with warps in a frame don't seem to work for base nfts\n\ncc @incarterseyes.eth @rawtoast @l444u",
"numberOfRecasts": 0,
"numberOfLikes": 0,
"channel": {
"channelId": "warpcast"
},
"mentions": [
{
"fid": "5952",
"position": 115
},
{
"fid": "17129",
"position": 116
},
{
"fid": "15037",
"position": 117
}
]
}
// Other casts casted since Jan 1, 2024
]
}
}
}
Get All Casts That Have Mentions
You can fetch all the casts casted that contain mentions by using the FarcasterCasts API and set the hasMentions filter to true:
Try Demo
Code
query MyQuery {
FarcasterCasts(
input: {
filter: {
# Make sure to set `hasMentions` to true
hasMentions: {_eq: true}
},
blockchain: ALL
}
) {
Cast {
castedAtTimestamp
embeds
url
text
numberOfRecasts
numberOfLikes
channel {
channelId
}
mentions {
fid
position
}
}
}
}
{
"data": {
"FarcasterCasts": {
"Cast": [
{
"castedAtTimestamp": "2024-02-27T19:07:28Z",
"embeds": [],
"url": "https://warpcast.com/qdau.eth/0x654ed051",
"text": "not siue if that's a warpcast or zora problem, but mint with warps in a frame don't seem to work for base nfts\n\ncc @incarterseyes.eth @rawtoast @l444u",
"numberOfRecasts": 0,
"numberOfLikes": 0,
"channel": {
"channelId": "warpcast"
},
"mentions": [
{
"fid": "5952",
"position": 115
},
{
"fid": "17129",
"position": 116
},
{
"fid": "15037",
"position": 117
}
]
}
// Other casts that have mentions
]
}
}
}
Get Details Of A Certain Cast By Cast URL
You can fetch all the details, including text, embeds, url, social capital value, etc., of a given cast by using the FarcasterCasts API and provide the cast's URL from Warpcast to the url filter:
You can fetch all the details, including text, embeds, url, social capital value, etc., of a given cast by using the FarcasterCasts API and provide the cast's hash to the hash filter:
If the cast is a reply and not a root cast, then you should use this query here.