Build "Sort Replies" on a cast using Neynar and OpenRanks' Global Ranking API
Sort Direct Replies in a cast for your client
Step 1: Getting Details of the Cast
// Step 1: Getting Details of the Cast
const castIdentifier = "https://warpcast.com/dwr.eth/0xb1e61e72"
const castType = "url"
const USER_FID = 2025Step 2: Accessing Responses with the Neynar API
// Step 2: Accessing Responses with the Neynar API
async function getCastWithResponses(castIdentifier, castType, viewerFID) {
const neynarCastResponsesBaseURL = `https://api.neynar.com/v2/farcaster/cast/conversation`
const urlCastResponsesParams = `identifier=${castIdentifier}&type=${castType}&reply_depth=1&include_chronological_parent_casts=false&viewer_fid=${viewerFID}`
const neynarCastResponsesURL = `${neynarCastResponsesBaseURL}?${urlCastResponsesParams}`
const neynarCastResponsesResponse = await fetch(neynarCastResponsesURL, {
headers: {
'Content-Type': 'application/json',
api_key: process.env.NEYNAR_API_KEY
},
})
const castWithResponses = await neynarCastResponsesResponse.json().then(res => res.conversation);
// console.log(castWithResponses)
return castWithResponses
}Step 3: Using OpenRanks APIs to find out Global Rank of the users who replied
Step 4: Adding Global Ranks to Direct Replies
Step 5: Sorting Replies by Authors' Global Rank
PreviousBuild Power Badges for your Client using Global & Personalized Ranking APIs by OpenRankNextClanker OpenRank Scores
Last updated

