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:
Name | Type | Description |
---|---|---|
start_timestamp | string | return only casts after this start_timestamp, specified as Epoch time (Unix timestamp) |
end_timestamp | string | return only casts before this end_timestamp, specified as Epoch time (Unix timestamp) |
channels | string[] | return only casts that belong to these channels, specified by channel urls (root_parent_url) |
languages | string[] | returns only casts that use these languages |
author_ids | string[] | returns only casts created by authors with these fids |
remove_author_ids | string[] | does not return casts created by authors with these fid's NOTE: this is ignored if author_ids is defined |
frames_only | boolean | whether to limit search to only frames |
embed_domains | string[] | return only casts with specific domains embedded |
ai_labels | string[] | 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 toprovider_metadata
'sfilters.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 sincechannel_id
is superrare andfilters.channels
is neynar. time_window
will correspond toprovider_metadata
'sfilter.start_timestamp
.filter.start_timestamp
will overridetime_window
in the root request, if both are present.
Updated about 2 months ago