Learn how to fetch username proofs data using Airstack Hubs API.
Get Username Proofs By Username
You can get username by a specific username by using Airstack Hubs API with the code below:
import { Metadata, getSSLHubRpcClient,} from"@farcaster/hub-nodejs";import { config } from"dotenv";config();constclient=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`);constmetadata=newMetadata();// Provide API key heremetadata.add("x-airstack-hubs",process.env.AIRSTACK_API_KEYasstring);// Fetch uers name proofs data with `getUserNameProof`constuserNameProofsRes=awaitclient.getUserNameProof( { name:newTextEncoder().encode("adityapk") }, metadata );console.log(userNameProofsRes.value);// After everything, close the RPC connectionclient.close(); }});
import { Metadata, getSSLHubRpcClient,} from"@farcaster/hub-nodejs";import { config } from"dotenv";config();constclient=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`);constmetadata=newMetadata();// Provide API key heremetadata.add("x-airstack-hubs",process.env.AIRSTACK_API_KEYasstring);// Fetch uers name proofs data with `getUserNameProofsByFid`constuserNameProofsRes=awaitclient.getUserNameProofsByFid( { fid:2 }, metadata );console.log(verificationRes.value);// After everything, close the RPC connectionclient.close(); }});
If you have any questions or need help regarding integrating username proofs data using AIrstack Hubs API into your Farcaster app, please join our Airstack's Telegram group.