Official TypeScript/JavaScript SDK for the VerifyForge Email Validation API.
- π Hybrid Validation - Syntax, MX records, SMTP verification, and disposable detection
- β‘ Fast & Reliable - Optimized for speed with smart caching
- π Bulk Processing - Validate up to 100 emails in a single request
- π― Type Safe - Full TypeScript support with comprehensive type definitions
- π‘οΈ Error Handling - Comprehensive error handling with custom error classes
- π Secure - API key authentication
- π¦ Universal - Works in Node.js and modern browsers
- π³ Tree-shakeable - ESM and CommonJS builds
npm install @verifyforge/sdkOr using yarn:
yarn add @verifyforge/sdkOr using pnpm:
pnpm add @verifyforge/sdkimport { VerifyForge } from '@verifyforge/sdk';
// Initialize the client
const client = new VerifyForge({ apiKey: 'your_api_key_here' });
// Validate a single email
const result = await client.validate('user@example.com');
if (result.data.isValid) {
console.log('β Email is valid!');
console.log(`Reachability: ${result.data.reachability}`);
} else {
console.log('β Email is invalid');
}
console.log(`Credits remaining: ${result.remainingCredits}`);import { VerifyForge } from '@verifyforge/sdk';
const client = new VerifyForge({ apiKey: 'your_api_key' });
// Validate an email
const result = await client.validate('test@example.com');
// Access validation details
console.log(`Email: ${result.data.email}`);
console.log(`Valid: ${result.data.isValid}`);
console.log(`Disposable: ${result.data.disposable}`);
console.log(`Role Account: ${result.data.roleAccount}`);
console.log(`Free Provider: ${result.data.freeProvider}`);
console.log(`Reachability: ${result.data.reachability}`);
// Check MX records
for (const mx of result.data.mxRecordsList) {
console.log(`MX: ${mx.exchange} (priority: ${mx.priority})`);
}
// SMTP analysis
const smtp = result.data.smtp;
if (smtp.connectionSuccessful) {
console.log(`SMTP accepts mail: ${smtp.acceptsMail}`);
}import { VerifyForge } from '@verifyforge/sdk';
const client = new VerifyForge({ apiKey: 'your_api_key' });
// Validate multiple emails
const emails = [
'user1@example.com',
'user2@example.com',
'user3@example.com',
];
const result = await client.validateBulk(emails);
// Summary statistics
console.log(`Total validated: ${result.data.summary.total}`);
console.log(`Duplicates removed: ${result.data.summary.duplicatesRemoved}`);
console.log(`Credits used: ${result.creditsUsed}`);
// Individual results
for (const item of result.data.results) {
const status = item.isValid ? 'β' : 'β';
console.log(`${status} ${item.email} - ${item.reachable}`);
}import {
VerifyForge,
VerifyForgeError,
AuthenticationError,
InsufficientCreditsError,
ValidationError,
} from '@verifyforge/sdk';
const client = new VerifyForge({ apiKey: 'your_api_key' });
try {
const result = await client.validate('test@example.com');
console.log(result);
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Invalid API key');
} else if (error instanceof InsufficientCreditsError) {
console.error('Not enough credits');
} else if (error instanceof ValidationError) {
console.error(`Validation error: ${error.message}`);
console.error(`Details: ${JSON.stringify(error.details)}`);
} else if (error instanceof VerifyForgeError) {
console.error(`API error: ${error.toString()}`);
} else {
console.error('Unknown error:', error);
}
}import { VerifyForge } from '@verifyforge/sdk';
// Custom base URL and timeout
const client = new VerifyForge({
apiKey: 'your_api_key',
baseUrl: 'https://custom-domain.com', // Optional
timeout: 60000, // Request timeout in milliseconds (default: 30000)
});The SDK is written in TypeScript and provides full type definitions:
import {
VerifyForge,
ValidationResponse,
BulkValidationResponse,
ValidationResult,
} from '@verifyforge/sdk';
const client = new VerifyForge({ apiKey: 'your_api_key' });
// Type-safe responses
const result: ValidationResponse = await client.validate('test@example.com');
const bulkResult: BulkValidationResponse = await client.validateBulk([
'test1@example.com',
'test2@example.com',
]);
// Access typed properties
const validation: ValidationResult = result.data;
console.log(validation.isValid); // TypeScript knows this is a boolean
console.log(validation.reachability); // TypeScript knows this is 'safe' | 'risky' | 'invalid' | 'unknown'The SDK works in modern browsers with native fetch support:
<script type="module">
import { VerifyForge } from 'https://unpkg.com/@verifyforge/sdk';
const client = new VerifyForge({ apiKey: 'your_api_key' });
const result = await client.validate('test@example.com');
console.log(result);
</script>Main client class for interacting with the VerifyForge API.
new VerifyForge(config: VerifyForgeConfig)Parameters:
config.apiKey(string, required): Your VerifyForge API keyconfig.baseUrl(string, optional): Base URL for the API. Defaults to"https://verifyforge.com"config.timeout(number, optional): Request timeout in milliseconds. Defaults to30000
Validate a single email address.
Parameters:
email(string): Email address to validate
Returns:
Promise<ValidationResponse>: Complete validation results
Throws:
ValidationError: If email format is invalidInsufficientCreditsError: If account has insufficient creditsAPIError: If validation fails
Validate multiple email addresses (up to 100).
Parameters:
emails(string[]): Array of email addresses to validate
Returns:
Promise<BulkValidationResponse>: Results for all emails with summary
Throws:
ValidationError: If email list is invalid or exceeds 100 emailsInsufficientCreditsError: If account has insufficient creditsAPIError: If validation fails
Get the configured base URL.
Get the configured timeout in milliseconds.
interface ValidationResponse {
success: boolean;
data: ValidationResult;
creditsUsed: number;
remainingCredits: number;
validationDuration?: number;
meta?: {
apiVersion?: string;
};
}interface ValidationResult {
email: string;
isValid: boolean;
syntax: SyntaxValidation;
mxRecordsList: MXRecord[];
smtp: SMTPAnalysis;
disposable: boolean;
roleAccount: boolean;
freeProvider: boolean;
reachability: 'safe' | 'risky' | 'invalid' | 'unknown';
suggestion?: string;
gravatar?: Gravatar;
}interface BulkValidationResponse {
success: boolean;
data: {
results: BulkValidationResult[];
summary: BulkValidationSummary;
};
creditsUsed: number;
remainingCredits: number;
duration?: number;
meta?: {
apiVersion?: string;
};
}All errors extend VerifyForgeError:
AuthenticationError: Invalid API key (401)InsufficientCreditsError: Insufficient credits (402)ValidationError: Request validation failed (400)RateLimitError: Rate limit exceeded (429)APIError: General API error (5xx)NetworkError: Network request failed
- Node.js 16.0.0 or higher
- Modern browser with
fetchsupport
# Clone the repository
git clone https://github.com/VerifyForge/typescript-sdk.git
cd typescript-sdk
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Run linter
npm run lint
# Format code
npm run format
# Type checking
npm run typecheck
# Watch mode for development
npm run dev- π§ Email: contact@verifyforge.com
- π Documentation: https://verifyforge.com/api-docs
- π Bug Reports: https://github.com/VerifyForge/typescript-sdk/issues
This project is licensed under the MIT License - see the LICENSE file for details.