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

Recommended Node version 22.x.x. It is also compatible with +v18 .

Getting Started

First, install Opportify via the npm package manager:

npm install --save @opportify/sdk-nodejs

Calling Email Insights

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', response);
} catch (error: unknown) {
console.error('error', error);
}
}

analyzeEmail();

Calling IP Insights

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

const clientIpInsights = new IPInsights({
version: '1.0',
apiKey: 'YOUR-API-KEY-HERE'
});

async function analyzeIP() {
try {
const response = await clientIpInsights.analyze({
ip: '8.8.8.8',
enableAI: true // only available for paid plans.
});
console.log('response', response);
} catch (error: unknown) {
console.error('error', error);
}
}

analyzeIP();