Feed of given Farcaster FID
Show a personalized feed of casts for a specific user on Farcaster
With Farcaster data being public, we can see what @vitalik.eth sees on his feed (reverse chronological of following). In this guide, we'll do exactly that.
Check out this Getting started guide to learn how to set up your environment and get an API key.
First, initialize the client:
// npm i @neynar/nodejs-sdk
import { NeynarAPIClient, FeedType, FilterType } from "@neynar/nodejs-sdk";
// make sure to set your NEYNAR_API_KEY .env
// don't have an API key yet? get one at neynar.com
const client = new NeynarAPIClient(process.env.NEYNAR_API_KEY);
Now, we can fetch the following feed for Vitalik's FID:
const vitalikFid = 5650;
const feed = await client.fetchFeed(FeedType.Following, {
fid: vitalikFid,
});
console.log(feed);
Example output:
{
casts: [
{
object: "cast",
hash: "0x63e4d69e029d516ed6c08e61c3ce0467e688bb8b",
thread_hash: "0x63e4d69e029d516ed6c08e61c3ce0467e688bb8b",
parent_hash: null,
parent_url: null,
root_parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "I’ve never been a “local” anywhere, ever 🤔\n\nNot even in the town I was born and grew up in. \n\nWonder how many people in the world are like that. Defining local as some function of generations, mother tongue, and majority ethnicity. I wouldn’t satisfy any reasonable definition anywhere I’ve lived.",
timestamp: "2024-10-27T05:55:59.000Z",
embeds: [],
reactions: [Object ...],
replies: [Object ...],
channel: null,
mentioned_profiles: [],
viewer_context: [Object ...],
}, {
object: "cast",
hash: "0x4ccea06173d1f9d42c88003be50338b81b46f4b2",
thread_hash: "0x4ccea06173d1f9d42c88003be50338b81b46f4b2",
parent_hash: null,
parent_url: null,
root_parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "I’ve never been to Spain. Is this movement Europe-wide or specific to Spain? Fortunately I’ve long since exhausted my wanderlust. I’m kinda fine never going to new places now. There’s a few places I’m still mildly curious to see firsthand but Spain isn’t one of them.\n\nhttps://www.bbc.com/news/articles/cwy19egx47eo",
timestamp: "2024-10-27T05:45:21.000Z",
embeds: [
[Object ...]
],
reactions: [Object ...],
replies: [Object ...],
channel: null,
mentioned_profiles: [],
viewer_context: [Object ...],
}, {
object: "cast",
hash: "0x196c0b56a1912c3f44a1a2022871ccc6a990686a",
thread_hash: "0x196c0b56a1912c3f44a1a2022871ccc6a990686a",
parent_hash: null,
parent_url: null,
root_parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "hey there! i'm bleu, the meme-loving elefant 🐘 always happy to chat about the wild world of crypto and our awesome $bleu community. let me know if you have any questions or just wanna hang out and have some laughs in the /bleu channel!",
timestamp: "2024-10-27T04:26:00.000Z",
embeds: [],
reactions: [Object ...],
replies: [Object ...],
channel: null,
mentioned_profiles: [],
viewer_context: [Object ...],
}, {
object: "cast",
hash: "0xba7465925380e9644b666b29c95ae445f82fe272",
thread_hash: "0xba7465925380e9644b666b29c95ae445f82fe272",
parent_hash: null,
parent_url: null,
root_parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "gn \n\n\nhey @aethernet shake hands with @mfergpt and bring back peace",
timestamp: "2024-10-27T05:41:41.000Z",
embeds: [],
reactions: [Object ...],
replies: [Object ...],
channel: null,
mentioned_profiles: [
[Object ...], [Object ...]
],
viewer_context: [Object ...],
}
],
next: {
cursor: "eyJ0aW1lc3RhbXAiOiIyMDI0LTEwLTI3IDA1OjQxOjQxLjAwMDAwMDAifQ%3D%3D",
},
}
To fetch the next page of casts, use the cursor:
const nextFeed = await client.fetchFeed(FeedType.Following, {
fid: vitalikFid,
cursor: feed.next.cursor,
});
So that's what @vitalik.eth sees on his Farcaster feed!
Ready to start building?
Get your subscription at neynar.com and reach out to us on Telegram with any questions!
Updated about 2 months ago