> ## 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.

# Farcaster Feed of NFT Owners

> Make a Farcaster feed showing casts from a specific set of users

<Info>
  ### Related API reference [Fetch Feed](/reference/fetch-feed)
</Info>

This guide demonstrates how to make a feed of Farcaster casts from users who own a specific NFT.

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

Before all that, initialize Neynar client:

<CodeGroup>
  ```javascript Javascript theme={"system"}
  // 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);
  ```
</CodeGroup>

First, we need to get the addresses owning Milady. We can use the [Alchemy NFT API](https://docs.alchemy.com/reference/getownersforcontract-v3) to get the addresses of users who own the NFT.

<CodeGroup>
  ```javascript Javascript theme={"system"}
  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);
  ```
</CodeGroup>

Next, get Farcaster FIDs of each address, then filter out any undefined values.

<CodeGroup>
  ```javascript Javascript theme={"system"}
  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);
  ```
</CodeGroup>

Lastly, fetch the feed using the FIDs.

<CodeGroup>
  ```javascript Javascript theme={"system"}
  const feedType = FeedType.Filter;
  const filterType=  FilterType.Fids;

  const feed = await client.fetchFeed({feedType,
    filterType,
    fids
  });

  console.log(feed);
  ```
</CodeGroup>

Example output:

<CodeGroup>
  ```json Json theme={"system"}
  {
    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=="
  }
  }
  ```
</CodeGroup>

Farcaster feed of Milady owners!

<Info>
  ### Ready to start building?

  Get your subscription at [neynar.com](https://neynar.com) and reach out to us on [Slack](https://neynar.com/slack) with any questions!
</Info>
