> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neynar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Notifications for FID

> Fetch notifications for any Farcaster user

> [!NOTE]
>
> ### Related API: [Fetch notifications for user](https://docs.neynar.com/reference/fetch-all-notifications.md)

This guide demonstrates how to fetch notifications (inbound mentions, replies, likes, recasts, quotes) of a Farcaster user with the Neynar SDK.

Check out this [Getting started guide](https://docs.neynar.com/docs/getting-started-with-neynar.md) to learn how to set up your environment and get an API key.

First, initialize the client:

```javascript Javascript theme={"system"}
import { NeynarAPIClient, Configuration } 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 config = new Configuration({
  apiKey: process.env.NEYNAR_API_KEY,
});

const client = new NeynarAPIClient(config);
```

Then fetch the notifications:

```javascript Javascript theme={"system"}
const dwrFID = 3;
const notifications = await client.fetchAllNotifications({fid:dwrFID});

console.log(notifications);
```

Example output:

```json theme={"system"}
{
  notifications: [
    {
      object: "notification",
      most_recent_timestamp: "2023-11-28T11:11:11.000Z",
      type: "likes",
      cast: [Object ...],
      reactions: [
        [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
      ]
    }, {
      object: "notification",
      most_recent_timestamp: "2023-11-28T11:10:56.000Z",
      type: "quote",
      cast: [Object ...],
      quotes: [
        [Object ...], [Object ...]
      ]
    }, {
      object: "notification",
      most_recent_timestamp: "2023-11-28T11:09:16.000Z",
      type: "likes",
      cast: [Object ...],
      reactions: [
        [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
      ]
    }, {
      object: "notification",
      most_recent_timestamp: "2023-11-28T11:05:59.000Z",
      type: "follows",
      follows: [
        [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
      ]
    }, {
      object: "notification",
      most_recent_timestamp: "2023-11-28T10:25:51.000Z",
      type: "likes",
      cast: [Object ...],
      reactions: [
        [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...],
        [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
      ]
    }
  ],
  next: {
    cursor: "eyJ0aW1lc3RhbXAiOiIyMDIzLTExLTI4IDEwOjI1OjUxLjAwMDAwMDAifQ=="
  }
}
```

So that's what @dwr.eth sees on his Farcaster notification! To fetch the next page of notifications, use the cursor:

```javascript Javascript theme={"system"}
const nextNotifications = await client.fetchAllNotifications({
  fid: dwrFID,
  cursor: notifications.next.cursor,
});
```

To only fetch specific types of notifications like replies, mentions, and quotes, use the fetchMentionAndReplyNotifications function:

```javascript Javascript theme={"system"}
const mentionsAndReplies = await client.fetchAllNotifications({
  fid: dwrFID,
});
console.log(mentionsAndReplies);
```

Example output:

```json theme={"system"}
{
  result: {
    notifications: [
      [Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
    ],
    next: {
      cursor: "eyJ0aW1lc3RhbXAiOiIyMDIzLTExLTI4IDA3OjI5OjI4LjAwMDAwMDAifQ=="
    }
  }
}
```

To fetch the next page of mentions and replies, use the cursor:

```javascript Javascript theme={"system"}
const nextMentionsAndReplies = await client.fetchAllNotifications({
  fid: dwrFID,
  cursor: mentionsAndReplies.next.cursor,
});
console.log(nextMentionsAndReplies);
```

That's it! You can now fetch notifications of any Farcaster user.

> [!NOTE]
>
> ### Ready to start building?
>
> Get your subscription at [neynar.com](https://neynar.com) and reach out to us at [support@ns.com](mailto:support@ns.com) with any questions!


## Related topics

- [How to fetch notifications for a Farcaster user](https://docs.neynar.com/docs/how-to-fetch-notification-for-a-user.md)
- [Send notifications](https://docs.neynar.com/reference/publish-frame-notifications.md)
- [Notifications in Channels](https://docs.neynar.com/docs/fetching-channel-specific-notification-in-farcaster.md)
- [Sending Notifications](https://docs.neynar.com/miniapps/guides/notifications.md)
- [Enabled notifications](https://docs.neynar.com/reference/app-host-get-user-state.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.