Related APIs: (1) For user by channel (2) For user by parent_urls
Fetching Channel-Specific Notifications
Say you have a Farcaster client focusing on a specific channel, and you want to fetch notifications for a specific FID for that specific channel. We got you covered! This guide will show you how to fetch notifications for a specific FID for a specific channel. Check out this Getting started guide to learn how to set up your environment and get an API key. First, initialize the client:Copy
Ask AI
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);
channel_name to parent_url mapping
All parent_url to channel_name mappings can be found at this Github repo, along with other channel metadata.This repo is open source so feel free to submit PRs for additional channel data if you see anything missing.Copy
Ask AI
const nounsChannelUrl =
"chain://eip155:1/erc721:0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03";
const userFID = 3;
const notifications = await client.fetchChannelNotificationsForUser({fid:userFID,channelIds: [
nounsChannelUrl,
]});
Copy
Ask AI
{
"notifications": [
{
"object": "notification",
"most_recent_timestamp": "2023-12-08T06:31:10.000Z",
"type": "mention",
"cast": {
"object": "cast_hydrated",
"hash": "0xd16b71018cc53c667e771bb4c13627555a32b5d4",
"thread_hash": "b7fc569081242aadeb29f8254931daf31c9e1017",
"parent_hash": "243f539607f4ea7b4117a169433c1ea8295d32fc",
"parent_url": null,
"parent_author": {
"fid": "3895"
},
"author": {
"object": "user",
"fid": 1079,
"custody_address": "0xeb31e335531c06ca4d8fe58bed841e9031de4ee4",
"username": "joshuafisher.eth",
"display_name": "Joshua Fisher",
"pfp_url": "https://i.imgur.com/1pn4CEg.jpg",
"profile": {
"bio": {
"text": "⌐◨-◨ ‘ing around. Working on Nouns Creative focused on narrative works. Music Publisher & Manager by day.",
"mentioned_profiles": []
}
},
"follower_count": 422,
"following_count": 149,
"verifications": [
"0xbd7dbab9aeb52d6c8d0e80fcebde3af4cc86204a"
],
"active_status": "active"
},
"text": "Would be tasty if we could buy this with Warps @dwr.eth",
"timestamp": "2023-12-08T06:31:10.000Z",
"embeds": [],
"reactions": {
"likes": [
{
"fid": 1898,
"fname": "boscolo.eth"
},
{
"fid": 14700,
"fname": "brsn"
},
{
"fid": 3,
"fname": "dwr.eth"
},
{
"fid": 576,
"fname": "nonlinear.eth"
}
],
"recasts": []
},
"replies": {
"count": 0
},
"mentioned_profiles": [
{
"object": "user",
"fid": 3,
"custody_address": "0x6b0bda3f2ffed5efc83fa8c024acff1dd45793f1",
"username": "dwr.eth",
"display_name": "Dan Romero",
"pfp_url": "https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_256/https://lh3.googleusercontent.com/MyUBL0xHzMeBu7DXQAqv0bM9y6s4i4qjnhcXz5fxZKS3gwWgtamxxmxzCJX7m2cuYeGalyseCA2Y6OBKDMR06TWg2uwknnhdkDA1AA",
"profile": {
"bio": {
"text": "Working on Farcaster and Warpcast.",
"mentioned_profiles": []
}
},
"follower_count": 30657,
"following_count": 2722,
"verifications": [
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2",
"0xa14b4c95b5247199d74c5578531b4887ca5e4909",
"0xb877f7bb52d28f06e60f557c00a56225124b357f",
"0x8fc5d6afe572fefc4ec153587b63ce543f6fa2ea"
],
"active_status": "active"
}
]
}
},
{
"object": "notification",
"most_recent_timestamp": "2023-12-08T06:09:50.000Z",
"type": "mention",
"cast": {
"object": "cast_hydrated",
"hash": "0xbf05b5bb119d4f1b8c514fbc75c23f9c8755dfd7",
"thread_hash": "f750ed31ece83fa486be9b37782d57d1b679f925",
"parent_hash": "bde97a78c48ed92ba01c2c2f0cfd521b52f524bc",
"parent_url": null,
"parent_author": {
"fid": "7143"
},
"author": {
"object": "user",
"fid": 1097,
"custody_address": "0xe12b01100a4be7e79ddbd5dd939c97d12e890ac7",
"username": "noun40",
"display_name": "Noun 40",
"pfp_url": "https://openseauserdata.com/files/faa77932343776d1237e5dd82aa12e76.svg",
"profile": {
"bio": {
"text": "cofounder/cto @ bitwise",
"mentioned_profiles": []
}
},
"follower_count": 15682,
"following_count": 55,
"verifications": [
"0xae65e700f3f8904ac1007d47a5309dd26f8146c0"
],
"active_status": "active"
},
"text": "oh hmm i wonder if there’s a way to expose this data of channel subscribers @dwr.eth @v?",
"timestamp": "2023-12-08T06:09:50.000Z",
"embeds": [],
"reactions": {
"likes": [
{
"fid": 194490,
"fname": "0xdbao"
},
{
"fid": 197459,
"fname": "cryptoworldao"
},
{
"fid": 193703,
"fname": "ai13"
}
],
"recasts": []
},
"replies": {
"count": 1
},
"mentioned_profiles": [
{
"object": "user",
"fid": 3,
"custody_address": "0x6b0bda3f2ffed5efc83fa8c024acff1dd45793f1",
"username": "dwr.eth",
"display_name": "Dan Romero",
"pfp_url": "https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_256/https://lh3.googleusercontent.com/MyUBL0xHzMeBu7DXQAqv0bM9y6s4i4qjnhcXz5fxZKS3gwWgtamxxmxzCJX7m2cuYeGalyseCA2Y6OBKDMR06TWg2uwknnhdkDA1AA",
"profile": {
"bio": {
"text": "Working on Farcaster and Warpcast.",
"mentioned_profiles": []
}
},
"follower_count": 30657,
"following_count": 2722,
"verifications": [
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2",
"0xa14b4c95b5247199d74c5578531b4887ca5e4909",
"0xb877f7bb52d28f06e60f557c00a56225124b357f",
"0x8fc5d6afe572fefc4ec153587b63ce543f6fa2ea"
],
"active_status": "active"
},
{
"object": "user",
"fid": 2,
"custody_address": "0x4114e33eb831858649ea3702e1c9a2db3f626446",
"username": "v",
"display_name": "Varun Srinivasan",
"pfp_url": "https://i.seadn.io/gae/sYAr036bd0bRpj7OX6B-F-MqLGznVkK3--DSneL_BT5GX4NZJ3Zu91PgjpD9-xuVJtHq0qirJfPZeMKrahz8Us2Tj_X8qdNPYC-imqs?w=500&auto=format",
"profile": {
"bio": {
"text": "Technowatermelon. Elder Millenial. Building Farcaster. \n\nnf.td/varun",
"mentioned_profiles": []
}
},
"follower_count": 27025,
"following_count": 974,
"verifications": [
"0x91031dcfdea024b4d51e775486111d2b2a715871",
"0x182327170fc284caaa5b1bc3e3878233f529d741"
],
"active_status": "active"
}
]
}
},
{
"object": "notification",
"most_recent_timestamp": "2023-12-03T23:35:12.000Z",
"type": "mention",
"cast": {
"object": "cast_hydrated",
"hash": "0x06dfafdffa7455c3fd0a617ce1b026bcf01211d1",
"thread_hash": "2695897f7265b116de992dde0a13865dda938eae",
"parent_hash": "7b00f3e12f26ff363555d4f94f64e547fde7379a",
"parent_url": null,
"parent_author": {
"fid": "7143"
},
"author": {
"object": "user",
"fid": 1097,
"custody_address": "0xe12b01100a4be7e79ddbd5dd939c97d12e890ac7",
"username": "noun40",
"display_name": "Noun 40",
"pfp_url": "https://openseauserdata.com/files/faa77932343776d1237e5dd82aa12e76.svg",
"profile": {
"bio": {
"text": "cofounder/cto @ bitwise",
"mentioned_profiles": []
}
},
"follower_count": 15682,
"following_count": 55,
"verifications": [
"0xae65e700f3f8904ac1007d47a5309dd26f8146c0"
],
"active_status": "active"
},
"text": "@dwr.eth @v would you agree? is there a more fundamental reason it’s whitelisted atm?",
"timestamp": "2023-12-03T23:35:12.000Z",
"embeds": [],
"reactions": {
"likes": [
{
"fid": 1356,
"fname": "farcasteradmin.eth"
}
],
"recasts": []
},
"replies": {
"count": 1
},
"mentioned_profiles": [
{
"object": "user",
"fid": 3,
"custody_address": "0x6b0bda3f2ffed5efc83fa8c024acff1dd45793f1",
"username": "dwr.eth",
"display_name": "Dan Romero",
"pfp_url": "https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_256/https://lh3.googleusercontent.com/MyUBL0xHzMeBu7DXQAqv0bM9y6s4i4qjnhcXz5fxZKS3gwWgtamxxmxzCJX7m2cuYeGalyseCA2Y6OBKDMR06TWg2uwknnhdkDA1AA",
"profile": {
"bio": {
"text": "Working on Farcaster and Warpcast.",
"mentioned_profiles": []
}
},
"follower_count": 30657,
"following_count": 2722,
"verifications": [
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2",
"0xa14b4c95b5247199d74c5578531b4887ca5e4909",
"0xb877f7bb52d28f06e60f557c00a56225124b357f",
"0x8fc5d6afe572fefc4ec153587b63ce543f6fa2ea"
],
"active_status": "active"
},
{
"object": "user",
"fid": 2,
"custody_address": "0x4114e33eb831858649ea3702e1c9a2db3f626446",
"username": "v",
"display_name": "Varun Srinivasan",
"pfp_url": "https://i.seadn.io/gae/sYAr036bd0bRpj7OX6B-F-MqLGznVkK3--DSneL_BT5GX4NZJ3Zu91PgjpD9-xuVJtHq0qirJfPZeMKrahz8Us2Tj_X8qdNPYC-imqs?w=500&auto=format",
"profile": {
"bio": {
"text": "Technowatermelon. Elder Millenial. Building Farcaster. \n\nnf.td/varun",
"mentioned_profiles": []
}
},
"follower_count": 27025,
"following_count": 974,
"verifications": [
"0x91031dcfdea024b4d51e775486111d2b2a715871",
"0x182327170fc284caaa5b1bc3e3878233f529d741"
],
"active_status": "active"
}
]
}
}
],
"next": {
"cursor": "eyJ0aW1lc3RhbXAiOiIyMDIzLTEyLTAzIDIzOjM1OjEyLjAwMDAwMDAifQ=="
}
}
Copy
Ask AI
const nextNotifications = await client.fetchChannelNotificationsForUser({
fid: userFID,
channelIds: [nounsChannelUrl],
cursor: notifications.next.cursor,
});