Show Farcaster casts that have attachments with Neynar
// npm i @neynar/nodejs-sdk
import { NeynarAPIClient, Configuration } from "@neynar/nodejs-sdk";
import { FeedType } 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 feedType = FeedType.Filter;
const filterType= "embed_url";
const embedUrl= "github.com";
const result = await client.fetchFeed({feedType,
filterType,
embedUrl
});
console.log(result);
github.com
with any other embed url to fetch casts linking to that url.
To fetch casts linking to youtube.com:
const feedType = FeedType.Filter;
const filterType= "embed_url";
const embedUrl= "youtube.com";
const result = await client.fetchFeed({feedType,
filterType,
embedUrl
});
console.log(result);
const feedType = FeedType.Filter;
const filterType= "embed_url";
const embedUrl= "open.spotify.com";
const result = await client.fetchFeed({feedType,
filterType,
embedUrl
});
console.log(result);
{
casts: [
{
object: "cast_hydrated",
hash: "0x9f617c43f00308cdb46b7b72f067b01557d53733",
thread_hash: "0x9f617c43f00308cdb46b7b72f067b01557d53733",
parent_hash: null,
parent_url: "chain://eip155:7777777/erc721:0xe96c21b136a477a6a97332694f0caae9fbb05634",
parent_author: [Object ...],
author: [Object ...],
text: "Yo, we got kids to raise and bills to pay, enemies to lay down when they stand in our way, it's only us \n\nhttps://open.spotify.com/track/0SlljMy4uEgoVPCyavtcHH",
timestamp: "2023-12-11T04:06:57.000Z",
embeds: [
[Object ...]
],
reactions: [Object ...],
replies: [Object ...],
mentioned_profiles: []
}, {
object: "cast_hydrated",
hash: "0xe70d9d52c5019b247fa93f76779296322676a4e5",
thread_hash: "0xe70d9d52c5019b247fa93f76779296322676a4e5",
parent_hash: null,
parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "For the Intuitives (Part 1)",
timestamp: "2023-12-11T02:11:27.000Z",
embeds: [
[Object ...]
],
reactions: [Object ...],
replies: [Object ...],
mentioned_profiles: []
}, {
object: "cast_hydrated",
hash: "0xee6719ac805758be5bd54744bec63b7ec0bc4d3e",
thread_hash: "0xee6719ac805758be5bd54744bec63b7ec0bc4d3e",
parent_hash: null,
parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "EP 214 Douglas Rushkoff on Leaving Social Media",
timestamp: "2023-12-11T02:11:18.000Z",
embeds: [
[Object ...]
],
reactions: [Object ...],
replies: [Object ...],
mentioned_profiles: []
}, {
object: "cast_hydrated",
hash: "0xebe7e89b1a3e91c96f99ecf3ce7d2797e3b118b6",
thread_hash: "0xebe7e89b1a3e91c96f99ecf3ce7d2797e3b118b6",
parent_hash: null,
parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "#64 AI & the Global Brain: Peter Russell",
timestamp: "2023-12-11T02:11:04.000Z",
embeds: [
[Object ...]
],
reactions: [Object ...],
replies: [Object ...],
mentioned_profiles: []
}, {
object: "cast_hydrated",
hash: "0x93276da072a2902a3568da21203588995e4ba752",
thread_hash: "0x93276da072a2902a3568da21203588995e4ba752",
parent_hash: null,
parent_url: null,
parent_author: [Object ...],
author: [Object ...],
text: "Systems Thinking - Tomas Bjorkman - Consciousness",
timestamp: "2023-12-11T02:10:26.000Z",
embeds: [
[Object ...]
],
reactions: [Object ...],
replies: [Object ...],
mentioned_profiles: []
}
],
next: {
cursor: "eyJ0aW1lc3RhbXAiOiIyMDIzLTEyLTExIDAyOjEwOjI2LjAwMDAwMDAifQ=="
}
}
const filter= "filter";
const filterType= "embed_url";
const cursor= result.next.cursor
const nextResult = await client.fetchFeed({filter,
filterType,
embedUrl,
cursor
});
Was this page helpful?