Fetch Farcaster Feeds
Farcaster Feed of NFT Owners
Fetch User Information
- User by Wallet Address
- Mutual Follows/Followers
- Username Search
- Mutes, Blocks, and Bans
Build Farcaster Mini Apps
- Create Mini App in < 60s
- Convert Web App to Mini App
- Send Notifications to Mini App Users
- Create Transaction Frames
- Mini App Metadata
- Cast Actions
- v1 Frames (Maintenance Mode)
Build Bots and Agents
- Create Farcaster Bot or Agent
- Listen for @bot Mentions
- Make Agents Prompt Transactions
Fetch Farcaster Feeds
- Trending Feed on Farcaster
- Channel Feeds
- Feed of Given Farcaster FID
- Farcaster Feed of NFT Owners
- Casts by Embed in Farcaster
- How to Use the Neynar Feed API
Onboard New Users
- Create New Farcaster Account
- SIWN: Connect Farcaster Accounts
- Fetch Signers
Write Data to Farcaster
- Choose the Right Signer
- Write Data with Managed Signers
- Like & Recast
Filter Spam, Low Quality Data
Run Queries on FC Data
- Choose Among Data Products
- Ingest Farcaster Data
- Indexer Service
- Hosted SQL
Render Farcaster in React
Fetch Cast Information
Get Events Via Webhooks
Get Farcaster Data on Base
Fetch Notifications
Create Onchain Transactions
Intersect Onchain & Social Data
Write Direct Casts
Get Farcaster Storage Data
Publish Actions on FC Apps
Explore Network Health
Get Hypersub Subscriptions
Contribute To Development
Fetch Farcaster Feeds
Farcaster Feed of NFT Owners
Make a Farcaster feed showing casts from a specific set of users
This guide demonstrates how to make a feed of Farcaster casts from users who own a specific NFT.
Check out this Getting started guide to learn how to set up your environment and get an API key.
Before all that, initialize Neynar client:
// npm i @neynar/nodejs-sdk
import { NeynarAPIClient, Configuration } from "@neynar/nodejs-sdk";
import { FeedType,FilterType } from "@neynar/nodejs-sdk/build/api/index.js";
// make sure to set your NEYNAR_API_KEY .env
// don't have an API key yet? get one at neynar.com
const config = new Configuration({
apiKey: process.env.NEYNAR_API_KEY,
});
const client = new NeynarAPIClient(config);
First, we need to get the addresses owning Milady. We can use the Alchemy NFT API to get the addresses of users who own the NFT.
const getAddr = async (nftAddr: string): Promise<string[]> => {
const apiKey = process.env.ALCHEMY_API_KEY;
const baseUrl = `https://eth-mainnet.g.alchemy.com/nft/v3/${apiKey}/getOwnersForContract?`;
const url = `${baseUrl}contractAddress=${nftAddr}&withTokenBalances=false`;
const result = await fetch(url, {
headers: { accept: "application/json" },
});
const data = await result.json();
return data.owners;
};
// milady maker contract address
const nftAddr = "0x5af0d9827e0c53e4799bb226655a1de152a425a5";
const addrs = await getAddr(nftAddr);
Next, get Farcaster FIDs of each address, then filter out any undefined values.
const fidLookup = async (addrs: string[]) => {
const fids = await Promise.all(
addrs.map(async (addr) => {
try {
const response = await client.fetchBulkUsersByEthOrSolAddress({
addresses: [addr],
});
return response ? response.result.user.fid : undefined;
} catch (error) {
return undefined;
}
})
);
return fids.filter((fid) => fid !== undefined);
};
const fids = await fidLookup(addrs);
Lastly, fetch the feed using the FIDs.
const feedType = FeedType.Filter;
const filterType= FilterType.Fids;
const feed = await client.fetchFeed({feedType,
filterType,
fids
});
console.log(feed);
Example output:
{
casts: [
{
object: "cast_hydrated",
hash: "0x4b02b1ef6daa9fe111d3ce871ec004936f19b979",
thread_hash: "0x4b02b1ef6daa9fe111d3ce871ec004936f19b979",
parent_hash: null,
parent_url: "https://veryinter.net/person",
parent_author: [Object ...],
author: [Object ...],
text: "What'd you buy for Black Friday / Cyber Monday?\n\nI got a new webcam and bought a Roomba+mop that I'm excited to fiddle with.",
timestamp: "2023-11-27T14:46:01.000Z",
embeds: [],
reactions: [Object ...],
replies: [Object ...],
mentioned_profiles: []
}, {
object: "cast_hydrated",
hash: "0xf1210d9eb6b21bbf3847ca5983539ed9c2baee13",
thread_hash: "0xf1210d9eb6b21bbf3847ca5983539ed9c2baee13",
parent_hash: null,
parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "Great couple days mostly off the internet. 🦃🤗\n\nAlso excited to be back in the mix.\n\nWhat will be the biggest stories to end the year?",
timestamp: "2023-11-27T14:44:19.000Z",
embeds: [],
reactions: [Object ...],
replies: [Object ...],
mentioned_profiles: []
}, {
object: "cast_hydrated",
hash: "0x7d3ad4be401c0050cf20a060ebbd108383b6357c",
thread_hash: "0x7d3ad4be401c0050cf20a060ebbd108383b6357c",
parent_hash: null,
parent_url: "https://foundation.app",
parent_author: [Object ...],
author: [Object ...],
text: "Consisting of 50 1/1 works, Ver Clausi's new drop Blaamius imagines life after the Anthropocene. His rich, colorful illustrations that meld subject and scenery remind me of old sci-fi comics and H.R. Giger in the best possible way. \nPrice: 0.025\nhttps://foundation.app/collection/bla-cebc",
timestamp: "2023-11-27T14:29:37.000Z",
embeds: [
[Object ...]
],
reactions: [Object ...],
replies: [Object ...],
mentioned_profiles: []
}
],
next: {
cursor: "eyJ0aW1lc3RhbXAiOiIyMDIzLTExLTI3IDE0OjI5OjM3LjAwMDAwMDAifQ=="
}
}
Farcaster feed of Milady owners!
Ready to start building?
Get your subscription at neynar.com and reach out to us on Telegram with any questions!
Was this page helpful?