Farcaster Feed of NFT Owners
Make a Farcaster feed showing casts from a specific set of users
Related topics
Follow NFT Owners on Farcaster Using NeynarMint NFT(s)Generate an NFT imageRelevant ownersSimulate NFT mint calldataWas this page helpful?
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Make a Farcaster feed showing casts from a specific set of users
// 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);
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);
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);
const feedType = FeedType.Filter;
const filterType= FilterType.Fids;
const feed = await client.fetchFeed({feedType,
filterType,
fids
});
console.log(feed);
{
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=="
}
}
Related topics
Follow NFT Owners on Farcaster Using NeynarMint NFT(s)Generate an NFT imageRelevant ownersSimulate NFT mint calldataWas this page helpful?