What does @vitalik.eth's Farcaster feed look like?

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);

Let's fetch @vitalik.eth's following:

const fetchAllFollowing = async (fid: number) => {
  let cursor: string | null = "";
  let users: unknown[] = [];
  do {
    const result = await client.fetchUserFollowing(fid, {
      limit: 150,
      cursor,
    });
    users = users.concat(result.result.users);
    cursor = result.result.next.cursor;
    console.log(cursor);
  } while (cursor !== "" && cursor !== null);

  return users;
};

const vitalikFID = 5650;
const vitalikFollowings = await fetchAllFollowing(vitalikFID);
const fids = vitalikFollowings.map((user) => user.fid);

console.log(fids);

Example output:

[ 20493, 20259, 4989, 19644, 18295, 18297, 18294, 16343, 10765, 8066, 37, 7596, 7318, 7236, 4873,
  4893, 5451, 43, 1786, 4606, 1325, 1287, 999, 880, 762, 702, 617, 576, 557, 548, 539, 528, 473, 472,
  457, 431, 426, 378, 373, 368, 359, 358, 347, 325, 312, 302, 283, 274, 258, 251, 239, 224, 207, 145,
  143, 134, 129, 127, 124, 108, 101, 99, 83, 73, 60, 56, 17, 12, 3, 2 ]

Now that we have the FIDs of @vitalik.eth's following, we can fetch their casts as a reverse chronological feed:

const feed = await client.fetchFeed(FeedType.Filter, {
  filterType: FilterType.Fids,
  fids,
});

console.log(feed);

Example output:

{
  casts: [
    {
      object: "cast_hydrated",
      hash: "0xb7799252fa2cc220e76be69638065e890e45be40",
      thread_hash: "0xb7799252fa2cc220e76be69638065e890e45be40",
      parent_hash: null,
      parent_url: null,
      parent_author: [Object ...],
      author: [Object ...],
      text: "For most of human history it’s always been about brands imposing their values onto the world, the rest of it seems to be about imposing personal values on brands. \n\nMaybe because of internet, and further decentralization?",
      timestamp: "2023-11-28T17:39:36.000Z",
      embeds: [],
      reactions: [Object ...],
      replies: [Object ...],
      mentioned_profiles: []
    }, {
      object: "cast_hydrated",
      hash: "0x54e0dabf2bfcae5077a1bf8035fd9d73fab88a4a",
      thread_hash: "0x54e0dabf2bfcae5077a1bf8035fd9d73fab88a4a",
      parent_hash: null,
      parent_url: null,
      parent_author: [Object ...],
      author: [Object ...],
      text: "“Can tech be governed?” is a question that rhymes eerily with the “can the economy be governed” question during the ZIRP era with all those discussions of zero lower bound, negative interest rates, and the discovery of QE as a dangerous (chemotherapy for cancer?) control mechanism with bad side effects later.",
      timestamp: "2023-11-28T17:28:47.000Z",
      embeds: [],
      reactions: [Object ...],
      replies: [Object ...],
      mentioned_profiles: []
    }, {
      object: "cast_hydrated",
      hash: "0x933ba996c0eb8251774aee91c577d8504cba094a",
      thread_hash: "0x933ba996c0eb8251774aee91c577d8504cba094a",
      parent_hash: null,
      parent_url: null,
      parent_author: [Object ...],
      author: [Object ...],
      text: "dear god,\nit's me, ted.\nplease protect warpcast \nfrom all of the self-congratulatory\nforbes 30u30 posts today.\nthank you for keeping us safe.\nlove,\nted",
      timestamp: "2023-11-28T17:09:23.000Z",
      embeds: [],
      reactions: [Object ...],
      replies: [Object ...],
      mentioned_profiles: []
    }, {
      object: "cast_hydrated",
      hash: "0x7489e11e4a5f9fb8b483cf4943af494134b4d206",
      thread_hash: "0x7489e11e4a5f9fb8b483cf4943af494134b4d206",
      parent_hash: null,
      parent_url: "chain://eip155:1/erc721:0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03",
      parent_author: [Object ...],
      author: [Object ...],
      text: "We pushed a few big updates last week to https://www.nounerkarma.xyz/ and wanted to share ✨",
      timestamp: "2023-11-27T17:58:11.000Z",
      embeds: [
        [Object ...], [Object ...]
      ],
      reactions: [Object ...],
      replies: [Object ...],
      mentioned_profiles: []
    }, {
      object: "cast_hydrated",
      hash: "0xb7b90be8ecb652b9a4c7024889edbe501e313755",
      thread_hash: "0xb7b90be8ecb652b9a4c7024889edbe501e313755",
      parent_hash: null,
      parent_url: "chain://eip155:7777777/erc721:0x5747eef366fd36684e8893bf4fe628efc2ac2d10",
      parent_author: [Object ...],
      author: [Object ...],
      text: "https://twitter.com/karpathy/status/1729545506890932536",
      timestamp: "2023-11-28T17:02:28.000Z",
      embeds: [
        [Object ...]
      ],
      reactions: [Object ...],
      replies: [Object ...],
      mentioned_profiles: []
    }
  ],
  next: {
    cursor: "eyJ0aW1lc3RhbXAiOiIyMDIzLTExLTI4IDE3OjAyOjI4LjAwMDAwMDAifQ=="
  }
}

To fetch the next page of casts, use the cursor:

const nextFeed = await client.fetchFeed(FeedType.Filter, {
  filterType: FilterType.Fids,
  fids,
  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!