Skip to main content

Getting Started with Node.js

Safe API Key Storage

In a production setup, do not store API Keys in the host's environment variables or in the source code.

Requirements

  • Node.js version supported: >20.x;

Install the Opportify SDK

Install Using a Package Manager

To start using the Opportify SDK in your Node.js project, you can install the Opportify SDK from your package manager of choice:

npm i @opportify/sdk-nodejs

Usage

Client

After you installed the library, you can create a client instance and interface with it.

import { IpInsights, EmailInsights } from '@opportify/sdk-nodejs';

const clientIpInsights = new IpInsights({
version: '1.0',
apiKey: 'YOUR_API_KEY'
});

const clientEmailInsights = new EmailInsights({
version: '1.0',
apiKey: 'YOUR_API_KEY'
})

Make a request

import { EmailInsights } from '@opportify/sdk-nodejs';

const clientEmailInsights = new EmailInsights({
version: '1.0',
apiKey: 'YOUR_API_KEY'
});

async function analyzeEmail() {
try {
const response = await clientEmailInsights.analyze({
email: "email_to_validate@domain.com",
enableAutoCorrection: true,
enableAI: true, // only available on paid plans.
});
console.log('response', JSON.stringify(response));
} catch (error) {
console.error(error);
}
}

analyzeEmail();

What's next?

How-To Guides

Once you have installed the Opportify SDK, you can start building your application. You can find usage examples in this Wiki's how-to guides.