Casts by embed in Farcaster
Show Farcaster casts that have attachments with Neynar
This guide demonstrates how to use the Neynar SDK to casts that contain a specific embed (eg. cast linking to github.com or youtube.com).
Check out this Getting started guide to learn how to set up your environment and get an API key.
First, initialize Neynar 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);
Then fetch casts linking to github.com:
const result = await client.fetchFeed("filter", {
filterType: "embed_url",
embedUrl: "github.com",
});
console.log(result);
Replace github.com
with any other embed url to fetch casts linking to that url.
To fetch casts linking to youtube.com:
const result = await client.fetchFeed("filter", {
filterType: "embed_url",
embedUrl: "youtube.com",
});
console.log(result);
And... Spotify:
const result = await client.fetchFeed("filter", {
filterType: "embed_url",
embedUrl: "open.spotify.com",
});
console.log(result);
Example output:
{
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=="
}
}
To fetch the next page:
const nextResult = await client.fetchFeed("filter", {
filterType: "embed_url",
embedUrl: "github.com",
cursor: result.next.cursor,
});
There you go, fetching casts with specific embeds in Farcaster with Neynar SDK!
Ready to start building?
Get your subscription at neynar.com and reach out to us on Telegram with any questions!
Updated 3 months ago