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

# JavaScript SDK

JavaScript & TypeScript Node.js

Integrate Nigerian National Identification Number (NIN) verification into your Node.js applications using the official LumiID JavaScript SDK.

The LumiID SDK provides a simple way to verify Nigerian identity information securely without manually handling HTTP requests.

Create a client using your LumiID API key, submit an identity type and identification number, and retrieve the verification response.

The SDK supports:

* JavaScript
* TypeScript
* ESM (ECMAScript Modules)
* CommonJS

## What you need

Before getting started, ensure you have:

* A valid LumiID API key.
* A server-side Node.js application.
* A valid test or production NIN.
* Node.js and npm installed.

Security requirement

NIN verification must be performed on your backend. Never expose your LumiID API key in browser code, frontend applications, or public repositories.

## 1. Install the SDK

Install the LumiID package using your preferred package manager.

npm

```javascript theme={null}
npm install lumiid
```

yarn

```javascript theme={null}
yarn add lumiid
```

pnpm

```javascript theme={null}
pnpm add lumiid
```

## 2. Configure your API key

Store your LumiID API key in an environment variable.

Create a `.env` file:

```dotenv theme={null}
LUMIID_API_KEY=your_lumiid_api_key
```

Install dotenv if your application does not already load environment variables:

```javascript theme={null}
npm install dotenv
```

Load the environment variables in your application:

```javascript theme={null}
import "dotenv/config";
```

Never commit your `.env` file to version control.

## 3. Quick start

Verify a Nigerian NIN using the LumiID JavaScript SDK.

### Verify a NIN

```javascript theme={null}
import { LumiID, LumiIDError } from "lumiid";

const client = new LumiID({
  apiKey: process.env.LUMIID_API_KEY,
});

const result = await client.verify({
  idType: "NIN",
  idNumber: "89184072280",
});

if (result instanceof LumiIDError) {
  console.error("Verification failed:", result.response);
} else {
  console.log("Verification successful:", result.response);
}
```

How it works:

1. Import `LumiID` and `LumiIDError`.
2. Initialize the SDK with your API key.
3. Call `client.verify()` with the identity type and number.
4. Check whether the response is an instance of `LumiIDError`.
5. Process the successful verification response.

The NIN above is an illustrative example. Use an authorized test or production identity number in your integration.

## 4. Use TypeScript

The LumiID SDK includes TypeScript declarations, so you can integrate it into TypeScript applications without installing additional type packages.

```typescript theme={null}
import { LumiID, LumiIDError } from "lumiid";

const client = new LumiID({
  apiKey: process.env.LUMIID_API_KEY,
});

const result = await client.verify({
  idType: "NIN",
  idNumber: "89184072280",
});

if (result instanceof LumiIDError) {
  console.error("Verification failed:", result.response);
} else {
  console.log("Verification successful:", result.response);
}
```

The SDK ships with TypeScript declarations through:

```text theme={null}
dist/index.d.ts
```

## 5. Use CommonJS

For applications using CommonJS, import the SDK with `require()`.

```javascript theme={null}
const { LumiID, LumiIDError } = require("lumiid");

const client = new LumiID({
  apiKey: process.env.LUMIID_API_KEY,
});

async function verifyNIN() {
  const result = await client.verify({
    idType: "NIN",
    idNumber: "89184072280",
  });

  if (result instanceof LumiIDError) {
    console.error("Verification failed:", result.response);
  } else {
    console.log("Verification successful:", result.response);
  }
}

verifyNIN();
```

## 6. Handle verification errors

The SDK returns a `LumiIDError` instance when LumiID cannot complete a verification request.

Always check the returned result before accessing the successful verification response.

```javascript theme={null}
const result = await client.verify({
  idType: "NIN",
  idNumber: "89184072280",
});

if (result instanceof LumiIDError) {
  console.error("Verification failed:", result.response);

  process.exitCode = 1;
} else {
  console.log("Verification succeeded:", result.response);
}
```

This allows your application to distinguish between successful verification responses and verification request failures.

## 7. Production checklist

Before deploying your integration, ensure that:

* Your API key is stored in a secure environment variable or secret manager.
* User input is validated before submitting verification requests.
* Verification requests are made exclusively from trusted server-side code.
* NINs and sensitive identity information are excluded from application logs.
* Verification errors are handled appropriately.
* Your production environment uses the correct LumiID API credentials.

## 8. Frequently asked questions

Does the LumiID SDK support TypeScript?

Yes. The package ships with TypeScript declarations in `dist/index.d.ts`.

Can I use the SDK in frontend applications?

No. The SDK requires a secret API key. Use it exclusively in trusted server-side environments such as Node.js backends.

Which module systems are supported?

The SDK supports both ESM and CommonJS.

* ESM: `import`
* CommonJS: `require()`

Do I need to make HTTP requests manually?

No. The SDK provides the `client.verify()` method to submit NIN verification requests.

Can I use the SDK with Express.js?

Yes. You can initialize the LumiID client in your Express.js backend and expose your own authenticated API route to your frontend.

## 9. Related documentation

* [NIN Verification API: REST API documentation for direct NIN verification integrations](https://docs.lumiid.com/api-reference/government-verification/Nigeria/nin-verification.md).
* [LumiID Developer Documentation](https://docs.lumiid.com/?utm_source=chatgpt.com): Explore additional LumiID integration resources.

Integrate identity verification into your applications with LumiID's developer tools and APIs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.