⚑GRPC API

Learn how to integrate Airstack Hubs GRPC API into your Farcaster app within minutes.

Step 1: Install Dependencies

First, install the necessary dependencies to your project:

npm i @farcaster/hub-nodejs dotenv

Step 2: Connect to GRPC API

Then, you can connect and call to Airstack Hubs GRPC API by using the @farcaster/hub-nodejs library offered by the Farcaster team by providing the GRPC URL with the Airstack API key added to the metadata field x-airstack-hubs:

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

config();

// Instantiate the gRPC client for a secure connection
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();
    // add API key here
    metadata.add("x-airstack-hubs", process.env.AIRSTACK_API_KEY as string);

    // After everything, close the RPC connection
    client.close();
  }
});

Next Steps

Once you have the GRPC API integrated, you can start exploring all the APIs offered:

Developer Support

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

More Resources

Last updated