activeStatus
field that can be used to filter out inactive Farcasters.
activeStatus
field to filter out active Farcasters.
inactiveFids
value can be passed to client.unfollowUser to unfollow inactive Farcasters.
Unfollow Farcaster users with Neynar
// npm i @neynar/nodejs-sdk
import { NeynarAPIClient } from "@neynar/nodejs-sdk";
// make sure to set your NEYNAR_API_KEY .env
// don't have an API key yet? get one at neynar.com
const client = new NeynarAPIClient(process.env.NEYNAR_API_KEY);
const signer = process.env.NEYNAR_SIGNER;
activeStatus
field that can be used to filter out inactive Farcasters.
const fid = 3;
const users = await client.fetchUserFollowing(fid);
console.log(users);
{
"result": {
"users": [
{
"fid": 3461,
"custodyAddress": "0x094ce1566a83b632e59d50e2aa9618d0f4dcd432",
"username": "jonahg",
"displayName": "Jonah Grant",
"pfp": {
"url": "https://i.imgur.com/x51eW6a.jpg"
},
"profile": {
"bio": {
"text": "Software engineer in New York City",
"mentionedProfiles": []
}
},
"followerCount": 15,
"followingCount": 0,
"verifications": [],
"activeStatus": "inactive",
"timestamp": "2023-12-09T05:01:59.000Z"
},
{
"fid": 18198,
"custodyAddress": "0x718aea83c0ee2165377335a0e8ed48f1c5a34d63",
"username": "alive.eth",
"displayName": "Ali Yahya",
"pfp": {
"url": "https://i.imgur.com/1PASQSb.jpg"
},
"profile": {
"bio": {
"text": "GP @a16zcrypto. Previously Google Brain, GoogleX, Stanford Computer Science.",
"mentionedProfiles": []
}
},
"followerCount": 88,
"followingCount": 76,
"verifications": [
"0x990a73079425d2b0ec746e3cc989e903306bb6c7"
],
"activeStatus": "inactive",
"timestamp": "2023-12-08T16:58:51.000Z"
},
{
"fid": 9528,
"custodyAddress": "0x80ef8b51dbba18c50b3451acea9deebc7dfcd131",
"username": "skominers",
"displayName": "Scott Kominers ",
"pfp": {
"url": "https://i.imgur.com/lxEkagM.jpg"
},
"profile": {
"bio": {
"text": "@a16zcrypto • Harvard/HBS • 🧩 • QED",
"mentionedProfiles": []
}
},
"followerCount": 289,
"followingCount": 190,
"verifications": [
"0x34202f199ef058302dcced326a0105fe2db53e12"
],
"activeStatus": "active",
"timestamp": "2023-12-08T16:56:30.000Z"
}
],
"next": {
"cursor": "eyJ0aW1lc3RhbXAiOiIyMDIzLTEyLTA4IDE2OjU2OjMwLjAwMDAwMDAiLCJmaWQiOjk1Mjh9"
}
}
}
activeStatus
field to filter out active Farcasters.
const inactiveFids = users.result.users
.filter((user) => user.activeStatus === "inactive")
.map((user) => user.fid);
console.log(inactiveFids); // [ 3461, 18198 ]
inactiveFids
value can be passed to client.unfollowUser to unfollow inactive Farcasters.
await client.unfollowUser(signer, inactiveFids);
{
"success": true,
"details": [
{
"success": true,
"target_fid": 3461
},
{
"success": true,
"target_fid": 18198
},
]
}
Was this page helpful?