On X (Twitter) profile page, there is a “Followed by A, B, C, and 10 others you follow”. This guide demonstrates how to use the Neynar SDK to make the same thing but for Farcaster.
Check out this Getting started guide to learn how to set up your environment and get an API key.
First, initialize the client:
// npm i @neynar/nodejs-sdkimport{NeynarAPIClient,Configuration}from"@neynar/nodejs-sdk";// make sure to set your NEYNAR_API_KEY .env// don't have an API key yet? get one at neynar.comconst config =newConfiguration({apiKey:process.env.NEYNAR_API_KEY,});const client =newNeynarAPIClient(config);
Say we want to get people @rish follows that also follows @manan. This is useful if we want to mutual connections between two users. We’ll fetch @rish’s followings first.