Implementation: Let’s use sdk to look up a user by their FID
Create index.ts file at root level
Copy
Ask AI
touch index.ts
Add the following code in index.ts
Copy
Ask AI
// index.tsimport { NeynarAPIClient, Configuration, isApiErrorResponse } from "@neynar/nodejs-sdk";const config = new Configuration({ apiKey: "<YOUR_API_KEY_HERE>", // Replace with your Neynar API Key.});const client = new NeynarAPIClient(config);(async () => { try { const fid = 19960; // 19960 (Required*) => fid of user we are looking for const viewerFid = 194; // 191 (Optional) => fid of the viewer // Get more info @ https://docs.neynar.com/reference/fetch-bulk-users const users = await client.fetchBulkUsers({ fids: [fid], viewerFid }); // Stringify and log the response console.log(JSON.stringify(users)); } catch (error) { // isApiErrorResponse can be used to check for Neynar API errors if (isApiErrorResponse(error)) { console.log("API Error", error.response.data); } else { console.log("Generic Error", error); } }})();