Fetching relevant holders for a coin

The API identifies relevant users on Farcaster who hold the same coin, based on the users followed by the viewer. The API works across EVM (Ethereum, Base, etc.) and Solana networks.

Overview

The fetch-relevant-fungible-owners API endpoint allows you to retrieve a list of relevant users who own a specific fungible token. This is particularly useful for applications that want to display social connections around token ownership.

Key Features

  • Network Support: EVM + Solana
  • Viewer Context: The API customizes the response based on the viewer_fid, respecting the viewer’s mutes and blocks.
  • Relevance: Returns users from the network who are most relevant to the viewer

API Endpoint

Endpoint

GET /fungible/owner/relevant

Parameters

  • contract_address (string, required): The contract address of the fungible asset.

    • Example: 0x0db510e79909666d6dec7f5e49370838c16d950f
  • networks (enum string): Network to fetch tokens from.

    • Example: ["base"]
  • viewer_fid (integer, required): The FID of the user to customize this response for. This will also return a list of owners that respects this user’s mutes and blocks.

    • Example: 194

Response

  • 200 OK: Successful response containing relevant fungible owners.

    • top_relevant_owners_hydrated: An array of user objects representing the top relevant owners.
    • all_relevant_owners_dehydrated: An array of user objects representing all relevant owners.
  • 400 Bad Request: The request was invalid, often due to missing or incorrect parameters.

Example Request

GET /fungible/owner/relevant?contract_address=0x0db510e79909666d6dec7f5e49370838c16d950f&networks=base&viewer_fid=194

Example Response

{
  "top_relevant_owners_hydrated": [
    {
      "fid": 123,
      "username": "alice.eth",
      "display_name": "Alice",
      "pfp_url": "https://example.com/alice.jpg"
    },
    {
      "fid": 456,
      "username": "bob.eth",
      "display_name": "Bob",
      "pfp_url": "https://example.com/bob.jpg"
    }
  ],
  "all_relevant_owners_dehydrated": [
    {
      "fid": 789,
      "username": "charlie.eth",
      "display_name": "Charlie",
      "pfp_url": "https://example.com/charlie.jpg"
    }
  ]
}

Implementation Example

To implement this API call in a JavaScript environment using the Neynar SDK, follow the steps below:

1

Initialize the Neynar Client

import { NeynarAPIClient, Configuration } from "@neynar/nodejs-sdk";

const config = new Configuration({
  apiKey: process.env.NEYNAR_API_KEY,
});

const client = new NeynarAPIClient(config);
2

Fetch Relevant Fungible Owners

async function fetchRelevantOwners(contractAddress, viewerFid) {
  try {
    const response = await client.fetchRelevantFungibleOwners({
      contract_address: contractAddress,
      networks: ["base"],
      viewer_fid: viewerFid,
    });
    console.log("Relevant Owners:", response);
  } catch (error) {
    console.error("Error fetching relevant owners:", error);
  }
}

fetchRelevantOwners("0x0db510e79909666d6dec7f5e49370838c16d950f", 194);

Conclusion

This guide provides the necessary steps to fetch relevant fungible token holders using the Neynar API. By leveraging this API, developers can enhance their applications with social insights into token ownership, fostering a more connected user experience.

For further information, refer to the Neynar API Documentation. If you have any questions or need support, feel free to reach out to us on Telegram.