description |
---|
Learn how to integrate Airstack Hubs GRPC API into your Farcaster app within minutes. |
First, install the necessary dependencies to your project:
{% tabs %} {% tab title="npm" %}
npm i @farcaster/hub-nodejs dotenv
{% endtab %}
{% tab title="yarn" %}
yarn add @farcaster/hub-nodejs dotenv
{% endtab %}
{% tab title="pnpm" %}
pnpm install @farcaster/hub-nodejs dotenv
{% endtab %}
{% tab title="bun" %}
bun install @farcaster/hub-nodejs dotenv
{% endtab %} {% endtabs %}
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
:
{% tabs %} {% tab title="@farcaster/hub-nodejs" %}
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();
}
});
{% endtab %} {% endtabs %}
Once you have the GRPC API integrated, you can start exploring all the APIs offered:
- Casts
- Reactions
- Links
- User Data
- FIDs
- Storage
- Username Proofs
- Verifications
- Message
- Hub Events
- Onchain Events
If you have any questions or need help regarding integrating Airstack GRPC API into your Farcaster app, please join our Airstack's Telegram group.