Getting started with Neynar NodeJS SDK

Easily call Neynar APIs with our nodejs sdk


This tutorials uses the Neynar nodejs sdk


  • Install Node.js
  • Optional: Install Yarn (Alternatively, npm can be used)

Project Setup

Initialize Project Directory

mkdir get-started-with-neynar-sdk
cd get-started-with-neynar-sdk

Install Neynar SDK along with typescript

Install using npm
npm i @neynar/nodejs-sdk  
npm i -D typescript

// or

Install using Yarn
yarn add @neynar/nodejs-sdk  
yarn add -D typescript

Initialize typescript environment

npx tsc --init

Implementation: Let's use sdk to look up a user by their FID

Create index.ts file at root level

touch index.ts

Add following code in index.ts

// index.ts

import { NeynarAPIClient, isApiErrorResponse } from "@neynar/nodejs-sdk";
import { AxiosError } from "axios";

// Instantiate the client
const client = new NeynarAPIClient("<YOUR_API_KEY_HERE>"); // Replace with your Neynar API Key.

(async () => {
  try {
    // 19960 (Required*) => fid of user  we are looking for
    // 191 (Optional) => fid of the viewer
    // Get more info @
    const user = await client.lookupUserByFid(19960, 191);

    // Stringify and log the response
  } catch (error) {
    // isApiErrorResponse can be used to check for Neynar API errors
    if (isApiErrorResponse(error)) {
      console.log("API Error",;
    } else {
      console.log("Generic Error", error);

Running the project

npx ts-node index.ts


You should see a response like this. (You might not get beautified/ formated response since we JSON.stringify the response in order to log everything)

  "result": {
    "user": {
      "fid": 19960,
      "custodyAddress": "0xd1b702203b1b3b641a699997746bd4a12d157909",
      "username": "shreyas-chorge",
      "displayName": "Shreyas",
      "pfp": {
        "url": ""
      "profile": {
        "bio": {
          "text": "Everyday regular normal guy | 👨‍💻 @neynar",
          "mentionedProfiles": []
      "followerCount": 13,
      "followingCount": 55,
      "verifications": ["0xd1b702203b1b3b641a699997746bd4a12d157909"],
      "activeStatus": "inactive",
      "viewerContext": {
        "following": true,
        "followedBy": false

Congratulations! 🎉 You successfully setup @neynar/nodejs-sdk and used it to look up a user by their FID!

⚠️ Caution: Please do not use @neynar/nodejs-sdk on browser since NEYNAR_API_KEY will be exposed in the bundle.


Ready to start building?

Get your subscription at and reach out to us on Telegram with any questions!