# Node.js SDK (ingest)

> Quickly integrate the Ours Privacy Node.js SDK using npm. Send test requests from the Track Events API reference.

Source: https://docs.oursprivacy.com/docs/nodejs

Use this page to install the Ours Privacy Node.js SDK and send events from your server. Every request takes your Ingest API source's API key as `token`. Copy it from the **API Keys** card on the source's **Settings** tab.

## Installation

Install the SDK via npm:

```bash
npm install @oursprivacy/server-sdk
```

For more details, visit the [NPM Repo](https://www.npmjs.com/package/@oursprivacy/server-sdk) | [Github Repo](https://github.com/with-ours/ingest-sdk-nodejs).

## Usage

Create a client and track an event:

```javascript
import OursPrivacy from '@oursprivacy/server-sdk';

const client = new OursPrivacy();

// Track an event
await client.track.event({
  token: 'your-source-token',
  event: 'Purchase',
  userId: 'user123',
});

// Identify a user
await client.visitor.upsert({
  token: 'your-source-token',
  userId: 'user123',
  userProperties: {
    email: 'user@example.com',
    first_name: 'John',
    last_name: 'Doe',
  },
});
```

## Next Steps

* [Ingest API Integration](https://docs.oursprivacy.com/docs/server-to-server-integration): match events to visitors, backfill past events, and test with a Test Mode key.
* [Track Events API reference](https://docs.oursprivacy.com/docs/reference/track) and [Identify Visitors API reference](https://docs.oursprivacy.com/docs/reference/identify): every field the SDK accepts.
* [Node.js SDK on GitHub](https://github.com/with-ours/ingest-sdk-nodejs): retries, timeouts, and error handling.
