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

# Node.js Server Quickstart

> Get started using the Node.js Server SDK

<Warning>
  **Deprecation Notice**

  This page demonstrates the Node Server SDK for Server API v3. The Node Server
  SDK now supports Server API v4. Please use the
  [latest Node Server quickstart](/docs/node-server-quickstart) instead.
</Warning>

## Overview

In this quickstart, you'll add Fingerprint to a [Node](https://nodejs.org/) server using the web framework [Fastify](https://fastify.dev/) to prevent fraudulent account creation.

The example use case in this quickstart is stopping new account fraud, where attackers create multiple fake accounts to abuse promotions, exploit systems, or evade bans. However, the steps you'll follow apply to most use cases. You can flag and block suspicious users by identifying the device behind each sign-up attempt, login, or transaction.

In this quickstart, you'll learn how to:

* Set up a Fastify server with a Fingerprint integration
* Retrieve visitor identification data using the Server API
* Block bots and suspicious devices
* Prevent multiple signups from the same device

This guide focuses on the backend integration and must be completed after identifying a visitor and generating a request ID. **Before starting this quickstart, start with one of the [frontend](/docs/v3/web-quickstarts-overview) or [mobile](/docs/v3/mobile-quickstarts-overview) quickstarts to see how to identify a visitor in your frontend.**

> Estimated time: \< 10 minutes

## Prerequisites

Before you begin, make sure you have the following:

* **A completed frontend or mobile Fingerprint implementation (See the quickstarts)**
* [Node.js](https://nodejs.org/) (v20 or later) and npm installed
* Your favorite code editor
* Basic knowledge of JavaScript

## 1. Get your secret API key

<Note>
  Before starting this quickstart, you should already have a frontend Fingerprint implementation
  that sends the `requestId` to your server. If not, pause here and check out one of the
  [frontend](/docs/v3/web-quickstarts-overview) or [mobile](/docs/v3/mobile-quickstarts-overview)
  quickstarts first.
</Note>

If you're ready:

1. Sign in and go to the [**API keys**](https://dashboard.fingerprint.com/api-keys) page in the Fingerprint dashboard.
2. Create a new **secret API key**.
3. Copy it somewhere safe so you can use it to retrieve full visitor identification data from the Server API.

## 2. Set up your project

To get started, set up a basic server. If you already have a project you want to use, you can skip to the next section.

1. Create a new Node project and install Fastify and the Fingerprint Node Server SDK:

```bash Terminal theme={"theme":"github-dark-dimmed"}
mkdir fingerprint-node-quickstart && cd fingerprint-node-quickstart
npm init -y
npm install fastify @fingerprintjs/fingerprintjs-pro-server-api
```

*Note: This quickstart is written for version 6.x of the Fingerprint Node Server SDK*

2. Enable ES modules by updating the type in your package.json to be `module`:

```json package.json theme={"theme":"github-dark-dimmed"}
{
  "type": "module"
}
```

3. Create a new file called `server.js` and add a basic Fastify server setup:

```javascript server.js theme={"theme":"github-dark-dimmed"}
import Fastify from "fastify";

const app = Fastify();

app.post("/api/create-account", async (request, reply) => {
  // We'll add Fingerprint logic here
  return reply.send({ status: "Account created!" });
});

app.listen({ port: 3000 }, (err) => {
  if (err) throw err;
  console.log("Server running on http://localhost:3000");
});
```

Here we are running the server at port 3000 and have created a new POST route for account creation. Note that the `/api/create-account` route should match what you have set up in your frontend implementation where you are sending the Fingerprint `requestId` to your server. Your server will receive the initial identification information from identifying a visitor on the frontend and use it to get the full visitor data on the backend.

## 3. Initialize Fingerprint and retrieve visitor data

Now you'll configure the Fingerprint Node Server SDK using your secret API key and use it to fetch detailed visitor data for each signup attempt.

When making the initial visitor identification request in the frontend, you received a `requestId`. This ID is unique to each identification event. Your server can then use the [Fingerprint Events API](/reference/v3/server-api-get-event) to retrieve complete identification data, including the trusted visitor ID and other actionable insights like whether they are using a VPN or are a bot.

1. At the top of your `server.js` file, import and initialize the SDK with your secret API key:

```javascript server.js theme={"theme":"github-dark-dimmed"}
import { FingerprintJsServerApiClient, Region } from "@fingerprintjs/fingerprintjs-pro-server-api";

const client = new FingerprintJsServerApiClient({
  apiKey: "SECRET_API_KEY", // Replace with your actual secret key
  region: Region.Global, // Change to your Fingerprint workspace region
});
```

*For a production implementation make sure to store and reference your secret key securely.*

2. In your `/api/create-account` route, retrieve the `requestId` you are sending from the frontend and fetch the full visitor identification details with `getEvent()`:

<Note>
  **requestId vs event\_id:** Depending on which quickstart you completed, your frontend may send
  either `requestId` (older SDKs) or `event_id` (v4 and newer). Both refer to the same
  identification event and work with the Server API in the same way. If you receive `event_id`, use
  it in place of `requestId` in the steps below.
</Note>

```javascript server.js theme={"theme":"github-dark-dimmed"}
app.post("/api/create-account", async (request, reply) => {
  const { requestId, username, password } = request.body;
  const event = await client.getEvent(requestId);

  //...
```

Using the `requestId` the Fingerprint server client will retrieve the full data for the visitor identification request. The returned object will contain the visitor ID, IP address, device and browser details, and Smart Signals like bot detection, incognito mode detection, and detections for VPN or virtual machine use.

You can see a full example of the event structure, and test it with your own device, in the [demo playground](https://demo.fingerprint.com/playground).

For additional checks to ensure the validity of the data coming from your frontend view [how to protect from client-side tampering and replay attacks](/docs/v3/protecting-from-client-side-tampering).

## 4. Block bots and suspicious devices

<Note>
  This optional step uses the Bot Detection Smart Signal which is available only on paid plans.
</Note>

A simple but powerful way to prevent fraudulent account creation is to block automated signups that come from bots. The `event` object includes the [Bot Detection Smart Signal](https://fingerprint.com/products/bot-detection/) that flags automated activity, making it easy to reject bot traffic.

1. Continuing in your `/api/create-account` route, check the bot signal returned in the `event` object:

```javascript server.js theme={"theme":"github-dark-dimmed"}
const botDetected = event.products.botd.data.bot.result !== "notDetected";

if (botDetected) {
  return reply.code(403).send({ error: "Failed to create account." });
}
```

This signal returns `good` for known bots like search engines, `bad` for automation tools, headless browsers, or other signs of automation, and `notDetected` when no bot activity is found. You can also layer in other Smart Signals to catch more suspicious devices. For example, you can use Fingerprint's [Suspect Score](/docs/v3/suspect-score) to determine when to add additional friction to create an account.

## 5. Prevent multiple signups from the same device

To catch repeated signups from the same device, you can use the `visitorId` from the Fingerprint identification event. By saving this ID alongside each created account, you can detect and block duplicate signups from the same device. We'll be using a simple database to demonstrate how this works with SQLite.

1. Install the SQLite package:

```bash Terminal theme={"theme":"github-dark-dimmed"}
npm install sqlite3
```

2. At the top of your `server.js` file, import and initialize the database:

```javascript server.js theme={"theme":"github-dark-dimmed"}
import sqlite3 from "sqlite3";

const db = new sqlite3.Database("database.db");

db.run(`
  CREATE TABLE IF NOT EXISTS accounts (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username TEXT,
    password TEXT,
    visitorId TEXT
  )
`);
```

3. In your `/api/create-account` route handler, after getting the event, extract the `visitorId`:

```javascript server.js theme={"theme":"github-dark-dimmed"}
const visitorId = event.products.identification.data.visitorId;
```

4. Check if this device has already created an account; if yes, block the account creation:

```javascript server.js theme={"theme":"github-dark-dimmed"}
// Check if the visitorId already exists in the database
const existingRow = await new Promise((resolve, reject) => {
  db.get("SELECT COUNT(*) as count FROM accounts WHERE visitorId = ?", [visitorId], (err, row) => {
    if (err) reject(err);
    resolve(row);
  });
});

if (existingRow.count > 0) {
  return reply.code(429).send({ error: "Failed to create account." });
}

// Otherwise, insert the new account
await new Promise((resolve, reject) => {
  db.run(
    "INSERT INTO accounts (username, password, visitorId) VALUES (?, ?, ?)",
    [username, password, visitorId],
    (err) => {
      if (err) reject(err);
      resolve();
    },
  );
});
```

This gives you a basic system to detect and block repeat signups. You can expand on this by allowing a limited number of accounts per device, adjusting your response based on business rules, only evaluating recent signups, etc.

<Info>
  This is a minimal example to show how to use the Fingerprint Node Server SDK. In a real
  application, make sure to implement proper security practices, especially around password handling
  and storage.
</Info>

## 6. Test your implementation

Now that everything is set up, you can test the full flow using your existing frontend.

### Before you test

If your frontend is running on a different port (like localhost:5173 or localhost:3001), you may run into CORS issues for testing. To quickly fix this for local development & testing:

1. Install the Fastify CORS plugin:

```bash Terminal theme={"theme":"github-dark-dimmed"}
npm install @fastify/cors
```

2. Import it in `server.js`, then register it right after creating your Fastify app:

```javascript server.js theme={"theme":"github-dark-dimmed"}
import cors from "@fastify/cors"; // New
const app = Fastify();
await app.register(cors); // New
```

### Test the implementation

1. Start your Fastify server:

```bash Terminal theme={"theme":"github-dark-dimmed"}
node server.js
```

2. In your frontend, trigger a sign-up request that sends the `requestId`, `username`, and `password` to your `/api/create-account` endpoint. To see the reply messages make sure to parse and display or console log the response from your server.
3. Within your frontend, input a username and password to create a user. Then try to create another user and see that the second attempt will be rejected.
4. Bonus: Try creating an account using a headless browser.

## Next steps

You now have a working backend fraud check using Fingerprint. From here, you can expand your logic with more Smart Signals, adjust thresholds based on your risk tolerance, or introduce additional checks for suspicious users.

These same techniques apply to a wide range of fraud prevention use cases, from detecting fake reviews to blocking payment abuse or preventing account takeovers.

To go further, check out the use case tutorials for step-by-step guides tailored to specific problems you can solve with Fingerprint.

Check out these related resources:

* [Node SDK Reference](https://github.com/fingerprintjs/node-sdk/tree/api-v3)
* [Vue frontend quickstart](/docs/v3/vue-quickstart)
* [API reference for the Events endpoint](/reference/v3/server-api-get-event)
* [Use case tutorial: Detecting new account fraud](/docs/v3/new-account-fraud-use-case-tutorial)
* [Low-latency identification with Sealed Client Results](/docs/v3/sealed-client-results)
