JavaScript Email Name Extraction API
Professional-grade API for extracting names from email addresses in Node.js, React, Express.js, and browser applications. AI-powered with 95%+ accuracy.
Quick Start
Get started in 30 seconds with a simple fetch call. No API key required.
// Simple browser example - just fetch and go
const response = await fetch(
'https://api.emailnameextractor.com/?q=john.smith@example.com'
);
const data = await response.json();
console.log(data[0].firstName); // "John"
console.log(data[0].lastName); // "Smith"
console.log(data[0].confidence); // 95
Node.js Integration
Basic Node.js Implementation
Simple async function for extracting names in any Node.js application.
const https = require('https');
async function extractNamesFromEmail(email) {
const url = `https://api.emailnameextractor.com/?q=${encodeURIComponent(email)}`;
return new Promise((resolve, reject) => {
https.get(url, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => resolve(JSON.parse(data)));
}).on('error', reject);
});
}
// Usage
const result = await extractNamesFromEmail('sarah.johnson@company.com');
console.log(`Name: ${result[0].firstName} ${result[0].lastName}`);
console.log(`Company: ${result[0].companyName}`);
console.log(`Confidence: ${result[0].confidence}%`);
Node.js with Axios (Recommended)
Modern approach using axios for cleaner async/await syntax.
const axios = require('axios');
class EmailNameExtractor {
constructor() {
this.baseURL = 'https://api.emailnameextractor.com';
}
async extractSingle(email) {
const response = await axios.get(this.baseURL, {
params: { q: email }
});
return response.data[0];
}
async extractBulk(emails) {
const emailList = Array.isArray(emails) ? emails.join(',') : emails;
const response = await axios.get(this.baseURL, {
params: { q: emailList }
});
return response.data;
}
async extractWithCache(email, useCache = true) {
const response = await axios.get(this.baseURL, {
params: {
q: email,
nocache: !useCache
}
});
return response.data[0];
}
}
// Usage
const extractor = new EmailNameExtractor();
// Single email
const person = await extractor.extractSingle('james.wilson@tech.io');
console.log(person);
// Bulk processing
const people = await extractor.extractBulk([
'alice@example.com',
'bob.smith@company.com',
'charlie.brown@startup.io'
]);
people.forEach(p => {
console.log(`${p.firstName} ${p.lastName} - ${p.companyName}`);
});
Express.js API Route
RESTful API Endpoint
Create a proxy endpoint in your Express.js application with error handling and validation.
const express = require('express');
const axios = require('axios');
const router = express.Router();
// POST /api/extract-names
router.post('/extract-names', async (req, res) => {
try {
const { email, emails } = req.body;
// Validate input
if (!email && !emails) {
return res.status(400).json({
error: 'Email or emails array required'
});
}
// Prepare email list
const emailList = emails ? emails.join(',') : email;
// Call Email Name Extractor API
const response = await axios.get(
'https://api.emailnameextractor.com',
{ params: { q: emailList } }
);
// Return enriched data
res.json({
success: true,
count: response.data.length,
data: response.data.map(person => ({
email: person.email,
firstName: person.firstName,
lastName: person.lastName,
fullName: `${person.firstName} ${person.lastName}`.trim(),
company: person.companyName,
confidence: person.confidence,
aiUsed: person.aiUsed
}))
});
} catch (error) {
console.error('Email extraction error:', error);
res.status(500).json({
success: false,
error: 'Failed to extract names',
message: error.message
});
}
});
module.exports = router;
React Integration
Custom React Hook
Reusable hook for email name extraction with loading states and error handling.
import { useState, useCallback } from 'react';
export const useEmailNameExtractor = () => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const [data, setData] = useState(null);
const extractName = useCallback(async (email) => {
setLoading(true);
setError(null);
try {
const response = await fetch(
`https://api.emailnameextractor.com/?q=${encodeURIComponent(email)}`
);
if (!response.ok) {
throw new Error('Failed to extract name');
}
const result = await response.json();
setData(result[0]);
return result[0];
} catch (err) {
setError(err.message);
throw err;
} finally {
setLoading(false);
}
}, []);
const extractBulk = useCallback(async (emails) => {
setLoading(true);
setError(null);
try {
const emailList = Array.isArray(emails) ? emails.join(',') : emails;
const response = await fetch(
`https://api.emailnameextractor.com/?q=${encodeURIComponent(emailList)}`
);
if (!response.ok) {
throw new Error('Failed to extract names');
}
const results = await response.json();
setData(results);
return results;
} catch (err) {
setError(err.message);
throw err;
} finally {
setLoading(false);
}
}, []);
return {
extractName,
extractBulk,
loading,
error,
data
};
};
React Component Example
Complete component with form, validation, and results display.
import React, { useState } from 'react';
import { useEmailNameExtractor } from './hooks/useEmailNameExtractor';
export const EmailExtractorForm = () => {
const [email, setEmail] = useState('');
const { extractName, loading, error, data } = useEmailNameExtractor();
const handleSubmit = async (e) => {
e.preventDefault();
if (email) {
await extractName(email);
}
};
return (
<div className="email-extractor">
<form onSubmit={handleSubmit}>
<div className="form-group">
<label htmlFor="email">Email Address</label>
<input
type="email"
id="email"
className="form-control"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="john.smith@example.com"
required
/>
</div>
<button
type="submit"
className="btn btn-primary"
disabled={loading}
>
{loading ? 'Extracting...' : 'Extract Name'}
</button>
</form>
{error && (
<div className="alert alert-danger mt-3">
Error: {error}
</div>
)}
{data && (
<div className="card mt-4">
<div className="card-body">
<h5 className="card-title">
{data.firstName} {data.lastName}
</h5>
<ul className="list-unstyled">
<li><strong>Email:</strong> {data.email}</li>
<li><strong>Company:</strong> {data.companyName}</li>
<li><strong>Confidence:</strong> {data.confidence}%</li>
<li><strong>AI Used:</strong> {data.aiUsed ? 'Yes' : 'No'}</li>
</ul>
</div>
</div>
)}
</div>
);
};
TypeScript Support
Type Definitions
Full TypeScript interface definitions for type-safe development.
// types.ts
export interface EmailNameResult {
email: string;
userId: string;
domain: string;
domainPrefix: string;
website: string;
firstName: string;
middleName: string;
lastName: string;
extractionMethod: string;
department: string;
companyName: string;
score: number;
confidence: number;
birthYear: number | null;
source: 'local' | 'AI';
aiUsed: boolean;
isDisposable: boolean;
emailQuality: 'standard' | 'disposable' | 'unknown';
riskLevel: 'low' | 'high' | 'unknown';
}
export interface EmailNameExtractorOptions {
nocache?: boolean;
debug?: boolean;
}
export class EmailNameExtractor {
private baseURL = 'https://api.emailnameextractor.com';
async extract(
email: string,
options?: EmailNameExtractorOptions
): Promise<EmailNameResult> {
const params = new URLSearchParams({ q: email });
if (options?.nocache) params.append('nocache', 'true');
if (options?.debug) params.append('debug', 'true');
const response = await fetch(`${this.baseURL}?${params}`);
if (!response.ok) {
throw new Error(`API error: ${response.statusText}`);
}
const data: EmailNameResult[] = await response.json();
return data[0];
}
async extractBulk(
emails: string[],
options?: EmailNameExtractorOptions
): Promise<EmailNameResult[]> {
const params = new URLSearchParams({
q: emails.join(',')
});
if (options?.nocache) params.append('nocache', 'true');
if (options?.debug) params.append('debug', 'true');
const response = await fetch(`${this.baseURL}?${params}`);
if (!response.ok) {
throw new Error(`API error: ${response.statusText}`);
}
return await response.json();
}
}
// Usage
const extractor = new EmailNameExtractor();
const result = await extractor.extract('developer@example.com');
console.log(result.firstName); // Type-safe!
Advanced Features
AI-Powered Extraction
Automatic fallback to GPT-4o for complex patterns. 95%+ accuracy on real-world emails.
Built-in Caching
Lightning-fast responses with intelligent caching. Average response time under 100ms.
Confidence Scoring
Each result includes a confidence score (50-100%) so you know the extraction reliability.
Disposable Detection
Automatically identifies temporary/disposable email addresses for fraud prevention.
Global Name Support
Handles international names, hyphenated names, and cultural variations correctly.
Bulk Processing
Process multiple emails in a single API call. Efficient batch processing support.
Response Format
Every API call returns a consistent JSON structure with rich metadata.
[
{
"email": "sarah.johnson@techcorp.com",
"userId": "sarahjohnson",
"domain": "techcorp.com",
"firstName": "Sarah",
"middleName": "",
"lastName": "Johnson",
"companyName": "techcorp",
"department": "",
"website": "https://www.techcorp.com",
"confidence": 95,
"score": 100,
"extractionMethod": "first_last",
"source": "local",
"aiUsed": false,
"isDisposable": false,
"emailQuality": "standard",
"riskLevel": "low",
"birthYear": null
}
]
Ready to Start Building?
No API key required. Start extracting names in your JavaScript app right now.
Full API Docs Try Live Demo