@sharpapi/sharpapi-node-detect-emails
v1.0.1
Published
SharpAPI.com Node.js SDK for detecting email addresses in text
Downloads
7
Maintainers
Readme

Email Detector API for Node.js
🎯 Detect and extract email addresses from text — powered by SharpAPI AI.
SharpAPI Email Detector parses text content and extracts any email addresses found within. Perfect for data validation, content moderation, and lead extraction from unstructured text.
📋 Table of Contents
Requirements
- Node.js >= 16.x
- npm or yarn
Installation
Step 1. Install the package via npm:
npm install @sharpapi/sharpapi-node-detect-emailsStep 2. Get your API key
Visit SharpAPI.com to get your API key.
Usage
const { SharpApiDetectEmailsService } = require('@sharpapi/sharpapi-node-detect-emails');
const apiKey = process.env.SHARP_API_KEY; // Store your API key in environment variables
const service = new SharpApiDetectEmailsService(apiKey);
const text = `
For support inquiries, please contact [email protected] or [email protected].
You can also reach our CEO at [email protected] for partnership opportunities.
`;
async function detectEmails() {
try {
// Submit detection job
const statusUrl = await service.detectEmails(text);
console.log('Job submitted. Status URL:', statusUrl);
// Fetch results (polls automatically until complete)
const result = await service.fetchResults(statusUrl);
console.log('Detected emails:', result.getResultJson());
} catch (error) {
console.error('Error:', error.message);
}
}
detectEmails();API Documentation
Methods
detectEmails(text: string): Promise<string>
Detects and extracts email addresses from the provided text.
Parameters:
text(string, required): The text content to scan for email addresses
Returns:
- Promise: Status URL for polling the job result
Example:
const statusUrl = await service.detectEmails(textWithEmails);
const result = await service.fetchResults(statusUrl);Response Format
The API returns detected emails in a structured format:
{
"emails": [
{
"email": "[email protected]",
"confidence": 1.0,
"domain": "example.com",
"username": "support"
},
{
"email": "[email protected]",
"confidence": 1.0,
"domain": "company.org",
"username": "john.doe"
}
]
}Examples
Basic Email Detection
const { SharpApiDetectEmailsService } = require('@sharpapi/sharpapi-node-detect-emails');
const service = new SharpApiDetectEmailsService(process.env.SHARP_API_KEY);
const sampleText = `
Contact our team at [email protected] or reach out to
the marketing department at [email protected].
`;
service.detectEmails(sampleText)
.then(statusUrl => service.fetchResults(statusUrl))
.then(result => {
const emails = result.getResultJson();
console.log(`Found ${emails.length} email addresses:`);
emails.forEach((email, index) => {
console.log(`${index + 1}. ${email.email}`);
});
})
.catch(error => console.error('Detection failed:', error));Custom Polling Configuration
const service = new SharpApiDetectEmailsService(process.env.SHARP_API_KEY);
// Customize polling behavior
service.setApiJobStatusPollingInterval(5); // Poll every 5 seconds
service.setApiJobStatusPollingWait(120); // Wait up to 2 minutes
const statusUrl = await service.detectEmails(text);
const result = await service.fetchResults(statusUrl);Use Cases
- Lead Generation: Extract email addresses from web pages, documents, or social media
- Data Validation: Verify and extract emails from user-submitted forms
- Content Moderation: Detect email addresses in user-generated content
- Email Harvesting: Collect contact information from business cards or documents
- Spam Detection: Identify suspicious email patterns in text
- Contact Management: Parse unstructured text to build contact databases
API Endpoint
POST /content/detect_emails
For detailed API specifications, refer to:
Related Packages
- @sharpapi/sharpapi-node-detect-phones - Phone number detection
- @sharpapi/sharpapi-node-detect-urls - URL detection
- @sharpapi/sharpapi-node-detect-address - Address detection
- @sharpapi/sharpapi-node-client - Full SharpAPI SDK
License
This project is licensed under the MIT License. See the LICENSE.md file for details.
Support
- Documentation: SharpAPI.com Documentation
- Issues: GitHub Issues
- Email: [email protected]
Powered by SharpAPI - AI-Powered API Workflow Automation
