@stopreg/stopreg
v2.1.0
Published
The official Node.js SDK for StopReg.
Maintainers
Readme
StopReg Node.js SDK
The official Node.js SDK for StopReg, providing advanced email and domain verification to protect your application from fraudulent registrations and disposable email addresses.
Features
- Email Verification: Check if an email is disposable, role-based, or blocked.
- Domain Verification: Verify domains for MX records and provider reputation.
- MX Record Lookup: Automated mail server verification.
- Provider Reputation: Identify high-risk providers and disposable email services.
- TypeScript Support: Fully typed for a better developer experience.
Installation
npm install @stopreg/stopreg
# or
pnpm add @stopreg/stopreg
# or
yarn add @stopreg/stopregQuick Start
Initialize the client with your StopReg API token (get one at stopreg.com/dashboard).
import { StopReg } from '@stopreg/stopreg';
const stopreg = new StopReg({
apiToken: 'your_api_token_here'
});
async function runCheck() {
// 1. Verify an email address
const emailResult = await stopreg.verification.checkEmail('[email protected]');
console.log('Is Disposable:', emailResult.data.classification.is_disposable);
// 2. Verify a domain
const domainResult = await stopreg.verification.checkDomain('gmail.com');
console.log('Provider:', domainResult.data.domain.provider);
}
runCheck();Usage
Email Verification
Check detailed metrics for any email address:
import { StopReg } from '@stopreg/stopreg';
const stopreg = new StopReg({ apiToken: '...' });
const result = await stopreg.verification.checkEmail('[email protected]');
console.log(result.data.input.email); // "[email protected]"
console.log(result.data.classification.is_disposable); // false
console.log(result.data.classification.is_role_based); // false
console.log(result.data.mail_server.mx_found); // trueDomain Verification
Verify a domain before allowing a user to register:
const result = await stopreg.verification.checkDomain('stopreg.com');
console.log(result.data.domain.name); // "stopreg.com"
console.log(result.data.domain.provider); // "google"
console.log(result.data.mail_server.mx_found); // trueError Handling
The SDK throws descriptive errors for invalid inputs or API issues.
try {
await stopreg.verification.checkEmail('invalid-email');
} catch (error) {
// "A valid email address is required."
console.log(error.message);
}License
MIT © StopReg
