Trending feed w/ external providers

Get Farcaster trending casts on a feed with other providers like OpenRank and MBD

To choose a different provider, simply pass in a different value in the provider field. neynar is set as the default.

If you pick mbd as provider, you can further customize your feed by passing in additional filter values in an optionalfilters object inside the provider_metadata field in the request e.g.

const provider_metadata = encodeURIComponent(JSON.stringify({
  "filters": {
    "channels": [
      "https://warpcast.com/~/channel/neynar"
    ],
    "languages": [
      "en"
    ],
    "author_ids": [
      "194",
      "191"
    ],
    // remove_author_fids only works when author_ids isn't passed in
    // "remove_author_ids": [
      // "18949"
    // ],
    "frames_only": false,
    "embed_domains": [
      "neynar.com",
      "frames.neynar.com"
    ],
    "ai_labels": [
      "science_technology"
    ]
  }
}));

The filters available for MBD are that you can pass in that object are:

NameTypeDescription
start_timestampstringreturn only casts after this start_timestamp, specified as Epoch time (Unix timestamp)
end_timestampstringreturn only casts before this end_timestamp, specified as Epoch time (Unix timestamp)
channelsstring[]return only casts that belong to these channels, specified by channel urls (root_parent_url)
languagesstring[]returns only casts that use these languages
author_idsstring[]returns only casts created by authors with these fids
remove_author_idsstring[]does not return casts created by authors with these fid's
NOTE: this is ignored if author_ids is defined
frames_onlybooleanwhether to limit search to only frames
embed_domainsstring[]return only casts with specific domains embedded
ai_labelsstring[]Return only casts that have these AI labels. Available values below.

Labels in topics category:

- arts_culture

- business_entrepreneurs

- celebrity_pop_culture

- diaries_daily_life

- family

- fashion_style

- film_tv_video

- fitness_health

- food_dining

- gaming

- learning_educational

- music

- news_social_concern

- other_hobbies

- relationships

- science_technology

- sports

- travel_adventure

- youth_student_life

Labels in sentiment category:

- positive

- neutral

- negative

Labels in emotion category:

- anger

- anticipation

- disgust

- fear

- joy

- love

- optimism

- pessimism

- sadness

- surprise

- trust

Labels in moderation category:

- llm_generated

- spam

- sexual

- hate

- violence

- harassment

- self_harm

- sexual_minors

- hate_threatening

- violencegraphic

Labels in web3_topics category:

- web3_nft

- web3_defi

- web3_infra

- web3_industry

- web3_consumer

A full request to the feed api with the custom mbd filters object looks like below

const provider_metadata = encodeURIComponent(JSON.stringify({
  "filters": {
    "channels": [
      "https://warpcast.com/~/channel/neynar"
    ],
    "languages": [
      "en"
    ],
    "author_ids": [
      "194",
      "191"
    ],
    "frames_only": false,
    "embed_domains": [
      "neynar.com",
      "frames.neynar.com"
    ],
    "ai_labels": [
      "science_technology"
    ]
  }
}));

const url = `https://api.neynar.com/v2/farcaster/feed/trending?limit=10&viewer_fid=3&time_window=24h&channel_id=superrare&provider=mbd&provider_metadata=${provider_metadata}`;

fetch(url, {
  method: 'GET',
  headers: {
    'accept': 'application/json',
    'api_key': 'NEYNAR_API_DOCS'
  }
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('error:', error));

Please note :

  • If channel_id is included in the request in addition to provider_metadata's filters.channels, channel_id's URL will be appended to filters.channels. In the above example, the results will include the results from Neynar as well as Superrare channels since channel_id is superrare and filters.channels is neynar.
  • time_window will correspond to provider_metadata's filter.start_timestamp. filter.start_timestamp will override time_window in the root request, if both are present.