πŸ”—Links

Learn how to fetch Links data using Airstack Hubs API.

Check If FID Is Following Target FID

You can get check if a given FID is following a target FID by using Airstack Hubs API with the code below:

import {
  Metadata,
  getSSLHubRpcClient,
} from "@farcaster/hub-nodejs";

const client = getSSLHubRpcClient("hubs-grpc.airstack.xyz");

client.$.waitForReady(Date.now() + 5000, async (e) => {
  if (e) {
    console.error(`Failed to connect to the gRPC server:`, e);
    process.exit(1);
  } else {
    console.log(`Connected to the gRPC server`);
    const metadata = new Metadata();
    // Provide API key here
    metadata.add("x-airstack-hubs", process.env.AIRSTACK_API_KEY as string);

    // Fetch link data with `getLink`
    const linkResult = await client.getLink(
      {
        targetFid: 2,
        fid: 6833,
        linkType: "follow",
      },
      metadata
    );
    console.log(linkResult.value);
    // After everything, close the RPC connection
    client.close();
  }
});

Get Followings By FID

You can get all followings of a given FID by using Airstack Hubs API with the code below:

import {
  Metadata,
  getSSLHubRpcClient,
} from "@farcaster/hub-nodejs";

const client = getSSLHubRpcClient("hubs-grpc.airstack.xyz");

client.$.waitForReady(Date.now() + 5000, async (e) => {
  if (e) {
    console.error(`Failed to connect to the gRPC server:`, e);
    process.exit(1);
  } else {
    console.log(`Connected to the gRPC server`);
    const metadata = new Metadata();
    // Provide API key here
    metadata.add("x-airstack-hubs", process.env.AIRSTACK_API_KEY as string);

    // Fetch link data with `getLinksByFid`
    const linkResult = await client.getLinksByFid(
      {
        fid: 6833,
      },
      metadata
    );
    console.log(linkResult.value);
    // After everything, close the RPC connection
    client.close();
  }
});

Get Followers By FID

You can get all followers of a given FID by using Airstack Hubs API with the code below:

import {
  Metadata,
  getSSLHubRpcClient,
} from "@farcaster/hub-nodejs";

const client = getSSLHubRpcClient("hubs-grpc.airstack.xyz");

client.$.waitForReady(Date.now() + 5000, async (e) => {
  if (e) {
    console.error(`Failed to connect to the gRPC server:`, e);
    process.exit(1);
  } else {
    console.log(`Connected to the gRPC server`);
    const metadata = new Metadata();
    // Provide API key here
    metadata.add("x-airstack-hubs", process.env.AIRSTACK_API_KEY as string);

    // Fetch link data with `getLinksByTarget`
    const linkResult = await client.getLinksByTarget(
      {
        targetFid: 6833,
      },
      metadata
    );
    console.log(linkResult.value);
    console.log(reactionsResult.value);
    // After everything, close the RPC connection
    client.close();
  }
});

Developer Support

If you have any questions or need help regarding integrating Links data using AIrstack Hubs API into your Farcaster app, please join our Airstack's Telegram group.

More Resources

Last updated