Learn how to fetch data from Farcaster channels, including their original host, followers, and participants who have interacted (either by casting or replying) within the channels.
To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
Get Channel Details
You can fetch a certain channel details by using the FarcasterChannels and providing the channel ID (e.g. /farcaster channel ID is "farcaster") to $channelId variable:
{"data": {"FarcasterChannels": {"FarcasterChannel": [ {"channelId":"farcaster","dappName":"Farcaster","createdAtTimestamp":"2023-08-02T22:33:26Z","dappSlug":"farcaster_v2_optimism","description":"Discussions about Farcaster on Farcaster (meta!)","followerCount":183058,"name":"Farcaster","url":"chain://eip155:7777777/erc721:0x4f86113fc3e9783cf3ec9a552cbb566716a57628", "imageUrl": "https://ipfs.decentralized-content.com/ipfs/bafkreialf5usxssf2eu3e5ct37zzdd553d7lg7oywvdszmrg5p2zpkta7u"
} ] } }}
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 The Most Followed Farcaster Channels
You can fetch all Farcaster channels sorted by their follower count in descending order by using the FarcasterChannels API:
Try Demo
Code
queryMyQuery { FarcasterChannels( input: {blockchain: ALL, # specify to sort in descending order by followerCountorder: {followerCount: DESC} } ) { FarcasterChannel { name channelId followerCount } }}
{"data": {"FarcasterChannels": {"FarcasterChannel": [ {"name":"Base","channelId":"base","followerCount":210254 },// Other most followed Farcaster channels ] } }}
Get All The Most Recently Created Farcaster Channels
You can fetch all Farcaster channels sorted by their creation timestamp in descending order by using the FarcasterChannels API:
Try Demo
Code
queryMyQuery { FarcasterChannels( input: {blockchain: ALL, # specify to sort in descending order by createdAtTimestamporder: {createdAtTimestamp: DESC} } ) { FarcasterChannel { name channelId createdAtTimestamp } }}
{"data": {"FarcasterChannels": {"FarcasterChannel": [ {"name":"translate","channelId":"translate","createdAtTimestamp":"2024-04-29T11:26:42Z" },// Other most followed Farcaster channels ] } }}
Get Followers Of A Channel
You can fetch all the followers of a Farcaster channel by using FarcasterChannelParticipants by providing the channel ID (e.g. /farcaster channel ID is "farcaster") to $channelId variable and specify channelActions to "follow" value:
If you are only looking for channel followers, click here.
You can fetch all the participants of a channel by using the FarcasterChannels and providing the channel ID (e.g. /farcaster channel ID is "farcaster") to $channelId variable:
You can fetch the original host of a Farcaster channel by using the FarcasterChannels and providing the channel ID (e.g. /farcaster channel ID is "farcaster") to $channelId variable:
You can fetch all the channel a given Farcaster user follows by using the FarcasterChannelParticipants and providing the participant's FID to $participant variable and specifying the channelActions to "follow":
{"data": {"FarcasterChannelParticipants": {"FarcasterChannelParticipant": [ {"channelName":"Farcaster Devs","channelId":"fc-devs","lastFollowedTimestamp":"2024-01-11T16:56:06Z" },// Other channels followed by betashop.eth ] } }}
Get All The Channels Of A Farcaster User Participates In
Channel participants includes users that:
followed the channel
casted in the channel
replied to a cast in a channel
If you are only looking for channel followers, click here.
You can fetch all the channel a given Farcaster user participates in (either have followed, casted, or replied to a cast) by using the FarcasterChannelParticipants and providing the participant's FID to $participant variable:
{"data": {"FarcasterChannelParticipants": {"FarcasterChannelParticipant": [ {"channelName":"Founders" }, {"channelName":"Farcaster Devs" }, {"channelName":"Farcaster" }// Other channels Farcaster user FID 602 participated in ] } }}
Get All Farcaster Users Who Casted In Certain Channel
You can fetch all Farcaster users who casted in a given channel by using the FarcasterChannelParticipants and providing the $channelActions variable with "cast" value and the channel ID (e.g. /farcaster channel ID is "farcaster") to $channelId variable:
Try Demo
Code
queryMyQuery { FarcasterChannelParticipants( input: {filter: {channelActions: {_eq: cast}, # Filter only for those who castedchannelId: {_eq: "warpcast"}, # Search in /warpcast channel },blockchain: ALL } ) { FarcasterChannelParticipant { participant { userAddress profileNamefid: userId } } }}
Get All Farcaster Users Who Casted In Certain Channel Since Certain Timestamp
You can fetch all Farcaster users who casted in a given channel since a certain time by using the FarcasterChannelParticipants and providing:
the "cast" value to the $channelActions variable,
the channel ID (e.g. /farcaster channel ID is "farcaster") to $channelId variable, and
the timestamp to the $lastActionTimestamp variable, e.g. 2024-02-01T00:00:00Z for Feb 1, 2024 at 00:00.
Try Demo
Code
queryMyQuery { FarcasterChannelParticipants( input: {filter: {channelActions: {_eq: cast}, # Filter only for those who castedchannelId: {_eq: "warpcast"}, # Search in /warpcast channel # Filter last timestamp to be "greater than or equal to" Feb 1st, 2024lastActionTimestamp: {_gte: "2024-02-01T00:00:00Z"} },blockchain: ALL } ) { FarcasterChannelParticipant { participant { userAddress profileNamefid: userId } } }}
{"data": {"FarcasterChannelParticipants": {"FarcasterChannelParticipant": [ {"participant": {"userAddress":"0xff9715817e8b4011ca564f6dcca74a051aaa15a7","profileName":"cepi21","fid":"250243" } }, {"participant": {"userAddress":"0x36ab2c5251b3282f023c2718e78f7e75924eb781","profileName":"itsmwamad","fid":"341677" } }, {"participant": {"userAddress":"0x6b75881c4319c25af8ab843dc071aa5f24557098","profileName":"sh68sana","fid":"320271" } }// Other users casted in /warpcast channel since Feb 1, 2024 ] } }}
Get All Farcaster Users Who Participates In A Channel And Following The Host
To fetch all Farcaster users who participates in a channel and following the host, you'll first need to fetch the original host of the channel:
Once you have the original host's FID, you can then use it as an input variable to check on each participant if they're following the original host or not:
{"originalHost":"fc_fid:602"// The original host's FID}
{"data": {"FarcasterChannelParticipants": {"FarcasterChannelParticipant": [ {"participant": {"userAddressDetails": {"socialFollowers": {"Follower": [ {"followerAddress": {"addresses": ["0x44e2c9d7a7fc841b9929f0f980acfe784bac82e0","0x0cf68416279c2a9bcdd0fa6cc4e0347ac3d55d7d" ],"socials": [ {// This user participates in /airstack channel// and follows the original host"profileName":"chuckstock","fid":"16405","userAssociatedAddresses": ["0x44e2c9d7a7fc841b9929f0f980acfe784bac82e0","0x0cf68416279c2a9bcdd0fa6cc4e0347ac3d55d7d" ],"followerCount":1957,"followingCount":136 } ] } } ] } } } }, {"participant": {"userAddressDetails": {"socialFollowers": {// This user does not follow the original host and can be filtered out"Follower":null } } } },// Other /airstack channel participants ] } }}
Here, you can simply filter out those who return null as they are a participant of the /airstack channel, but does not follow the original host.
Get All Farcaster Channel Participants That Also Have A Power Badge
You can fetch all the channel participants of a Farcaster channel and check if they have a power badge by using the FarcasterChannelParticipants API:
{"data": {"FarcasterChannelParticipants": {"FarcasterChannelParticipant": [ {"participantId":"247143","participant": {"profileName":"kylepatrick","isFarcasterPowerUser":true// This user have power badge } }, {"participantId":"5701","participant": {"profileName":"chriscocreated","isFarcasterPowerUser":false// This user have no power badge } }, ] } }}
Check If Farcaster User Has Followed A Given Channel
You can check if Farcaster user has followed a given channel by using the FarcasterChannelParticipants API and providing:
the "follow" value to the $channelActions variable,
the channel ID (e.g. /farcaster channel ID is "farcaster") to $channelId variable, and