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

# Trending Feed on Farcaster - Neynar API

> Complete tutorial on fetching trending casts and popular content from the Farcaster network using Neynar SDK. Learn to implement trending feeds, discover viral content, and build engaging social media experiences with real-time trending algorithms and content discovery.

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

## How to Get Trending Casts

This guide demonstrates how to use the Neynar SDK to get trending casts on Farcaster.

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

First, initialize the client:

<CodeGroup>
  ```javascript Javascript theme={"system"}
  // npm i @neynar/nodejs-sdk
  import { Configuration, NeynarAPIClient } from "@neynar/nodejs-sdk";
  import { FeedType, FilterType } from "@neynar/nodejs-sdk/build/api";

  // 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>

Then fetch the global trending Farcaster casts:

<CodeGroup>
  ```javascript Javascript theme={"system"}
  const feed = await client.fetchFeed({
      feedType: FeedType.Filter,
      filterType: FilterType.GlobalTrending,
      limit: 1,
    })

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

Example output:

```json theme={"system"}
{
   "casts": [
      {
         "object": "cast",
         "hash": "0x40b187be167c0134bc99c7e131aedd1da591f3fc",
         "author": {
            "object": "user",
            "fid": 15983,
            "username": "jacek",
            "display_name": "Jacek.degen.eth 🎩",
            "pfp_url": "https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/85b47d38-7b53-46b0-7e6a-80ec1b9b3d00/original",
            "custody_address": "0x4ae49f0aa762efebebff4bac4ea0847eb6af4ec9",
            "profile": {
               "bio": {
                  "text": "Lead $DEGEN | https://www.degen.tips/"
               }
            },
            "follower_count": 77350,
            "following_count": 983,
            "verifications": [
               "0x495d4d2203be7775d22ee8f84017544331300d09",
               "0xf1e7dbedd9e06447e2f99b1310c09287b734addc",
               "0x011c9a600fa4dcc460f9864e9c8b5498c2835e5a"
            ],
            "verified_addresses": {
               "eth_addresses": [
                  "0x495d4d2203be7775d22ee8f84017544331300d09",
                  "0xf1e7dbedd9e06447e2f99b1310c09287b734addc",
                  "0x011c9a600fa4dcc460f9864e9c8b5498c2835e5a"
               ],
               "sol_addresses": []
            },
            "verified_accounts": [
               {
                  "platform": "x",
                  "username": "degentokenbase"
               }
            ],
            "power_badge": true
         },
         "thread_hash": "0x40b187be167c0134bc99c7e131aedd1da591f3fc",
         "parent_hash": null,
         "parent_url": "chain://eip155:7777777/erc721:0x5d6a07d07354f8793d1ca06280c4adf04767ad7e",
         "root_parent_url": "chain://eip155:7777777/erc721:0x5d6a07d07354f8793d1ca06280c4adf04767ad7e",
         "parent_author": {
            "fid": null
         },
         "text": "Daily Discussion Thread - /degen - February 12, 2025",
         "timestamp": "2025-02-12T11:00:28.000Z",
         "embeds": [
            {
               "url": "https://supercast.mypinata.cloud/ipfs/Qmd6kGygZGMvgXikYvMDZ6eBQAzFLYkx8CxAgkzq8wZrXT?filename=degen_is_the_ticker.jpg",
               "metadata": {
                  "content_type": "image/jpeg",
                  "content_length": 218324,
                  "_status": "RESOLVED",
                  "image": {
                     "width_px": 720,
                     "height_px": 722
                  }
               }
            }
         ],
         "channel": {
            "object": "channel_dehydrated",
            "id": "degen",
            "name": "Degen",
            "image_url": "https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/4728a50a-1669-4334-1f57-9473c04a2500/original"
         },
         "reactions": {
            "likes_count": 47,
            "recasts_count": 6,
            "likes": [
               {
                  "fid": 406308,
                  "fname": "huncho.eth"
               },
               {
                  "fid": 545237,
                  "fname": "robert-ryce"
               },
               {
                  "fid": 345765,
                  "fname": "adexmakai.eth"
               },
               {
                  "fid": 562503,
                  "fname": "araizkyani"
               },
               {
                  "fid": 430462,
                  "fname": "yaza69759996"
               }
            ],
            "recasts": [
               {
                  "fid": 279606,
                  "fname": "itsfarahnaz.eth"
               },
               {
                  "fid": 477126,
                  "fname": "mikadoe.eth"
               },
               {
                  "fid": 510796,
                  "fname": "drrrner"
               },
               {
                  "fid": 440352,
                  "fname": "thegoldenbright"
               },
               {
                  "fid": 526510,
                  "fname": "mariabazooka"
               }
            ]
         },
         "replies": {
            "count": 17
         },
         "mentioned_profiles": [],
         "author_channel_context": {
            "role": "moderator",
            "following": true
         }
      }
   ],
   "next": {
      "cursor": "eyJ0aW1lc3RhbXAiOiIyMDI1LTAyLTEyIDExOjAwOjI4LjAwMDAwMDAiLCJwb2ludHMiOjAuNDg1NTY2NX0%3D"
   }
}
```

To fetch the next page of the feed, use the cursor:

<CodeGroup>
  ```javascript Javascript theme={"system"}
  const nextFeed = await client.fetchFeed({
      feedType: FeedType.Filter,
      filterType: FilterType.GlobalTrending,
      limit: 1,
      cursor: feed.next.cursor,
    })
  ```
</CodeGroup>

It's that easy to get trending casts in Farcaster!

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