> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neynar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started with Neynar NodeJS SDK

> Easily call Neynar APIs with our nodejs sdk

<Info>
  This tutorials uses the [Neynar nodejs sdk](https://github.com/neynarxyz/nodejs-sdk)
</Info>

## Prerequisites

* Install [Node.js](https://nodejs.org/en/download/package-manager)
* Optional: Install [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable) (Alternatively, npm can be used)

## Project Setup

**Initialize Project Directory**

<CodeGroup>
  ```bash Shell theme={"system"}
  mkdir get-started-with-neynar-sdk
  cd get-started-with-neynar-sdk
  ```
</CodeGroup>

**Install Neynar SDK along with typescript**

Install using npm

<CodeGroup>
  ```bash Shell theme={"system"}
  npm i @neynar/nodejs-sdk
  npm i -D typescript
  ```
</CodeGroup>

// or

Install using Yarn

<CodeGroup>
  ```bash Shell theme={"system"}
  yarn add @neynar/nodejs-sdk
  yarn add -D typescript
  ```
</CodeGroup>

**Initialize typescript environment**

<CodeGroup>
  ```bash Shell theme={"system"}
  npx tsc --init
  ```
</CodeGroup>

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

Create index.ts file at root level

<CodeGroup>
  ```bash Shell theme={"system"}
  touch index.ts
  ```
</CodeGroup>

Add the following code in index.ts

<CodeGroup>
  ```typescript Typescript theme={"system"}
  // index.ts

  import { 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);
      }
    }
  })();
  ```
</CodeGroup>

## Running the project

<CodeGroup>
  ```shell shell theme={"system"}
  npx ts-node index.ts
  ```
</CodeGroup>

## Result

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

<CodeGroup>
  ```json JSON theme={"system"}
  {
    "users": [
      {
        "object": "user",
        "fid": 19960,
        "username": "shreyas-chorge",
        "display_name": "Shreyas",
        "pfp_url": "https://i.imgur.com/LPzRlQl.jpg",
        "custody_address": "0xd1b702203b1b3b641a699997746bd4a12d157909",
        "profile": {
          "bio": {
            "text": "Everyday regular normal guy | 👨‍💻 @neynar ..."
          },
          "location": {
            "latitude": 19.22,
            "longitude": 72.98,
            "address": {
              "city": "Thane",
              "state": "Maharashtra",
              "country": "India",
              "country_code": "in"
            }
          }
        },
        "follower_count": 250,
        "following_count": 92,
        "verifications": [
          "0xd1b702203b1b3b641a699997746bd4a12d157909",
          "0x7ea5dada4021c2c625e73d2a78882e91b93c174c"
        ],
        "verified_addresses": {
          "eth_addresses": [
            "0xd1b702203b1b3b641a699997746bd4a12d157909",
            "0x7ea5dada4021c2c625e73d2a78882e91b93c174c"
          ],
          "sol_addresses": []
        },
        "verified_accounts": null,
        "power_badge": false,
        "viewer_context": {
          "following": true,
          "followed_by": true,
          "blocking": false,
          "blocked_by": false
        }
      }
    ]
  }
  ```
</CodeGroup>

## Congratulations! You successfully setup [@neynar/nodejs-sdk](https://github.com/neynarxyz/nodejs-sdk) and used it to look up a user by their FID!

<Warning>
  Please do not use @neynar/nodejs-sdk on browser since NEYNAR\_API\_KEY will be exposed in the bundle.
</Warning>

<Info>
  ### Ready to start building?

  Get your subscription at [neynar.com](https://neynar.com) and reach out to us on [Slack](https://neynar.com/slack) with any questions!
</Info>
