How to Add Real-Time Email Verification to Your App in 10 Minutes
As a developer, ensuring data integrity at the point of entry is crucial for building robust and reliable applications. Email addresses are the cornerstone of user identity, communication, and marketing. A single invalid email can lead to failed sign-ups, undelivered notifications, and a poor user experience.
This guide will show you how to use a simple REST API to both validate email addresses in real-time on your frontend and programmatically clean an existing email list on your backend. We'll be using the Email Verify API, which provides a comprehensive JSON response that goes far beyond a simple valid/invalid check.
Step 1: Getting Started - Your API Key
First things first, you'll need an API key.
- Sign up for a free account at juhapi.com.
- Navigate to your dashboard and generate a new app to get a key.
- Keep it handy—we'll use it in all our requests.
Step 2: Anatomy of the API Call & Response
The API is designed for simplicity and power.
- The Endpoint:
https://hub.juheapi.com/email_verify/v1/verify
- Request Parameters: A simple GET request with two query parameters:
key
: Your API key.email
: The email address to verify.
- The Rich JSON Response: The real power lies in the detailed response. Here are the most valuable fields for a developer:
"is_deliverable"
: The final, all-encompassing boolean result. Your primary go/no-go indicator."did_you_mean"
: An invaluable string suggestion for common typos (e.g.,gmial.com
->gmail.com
)."is_disposable"
: A boolean that flags temporary "burner" emails. Crucial for fraud prevention."is_role_account"
: A boolean that identifies generic inboxes likeinfo@
,contact@
, etc."is_catch_all"
: A boolean indicating the domain accepts mail for any address, which can be risky for deliverability."score"
: A numeric confidence score (0-1) for quick, easy implementation of validation logic.
Step 3: Implementation Recipes
Let's write some code.
Recipe 1: Real-Time Form Validation (JavaScript fetch
****)
This snippet shows how to validate an email address as the user types, providing instant, helpful feedback.
<!-- HTML Form -->
<label for="email">Email Address:</label>
<input type="email" id="email" onblur="validateEmail()">
<p id="email-feedback" style="font-size: 14px;"></p>
<script>
async function validateEmail() {
const input = document.getElementById('email');
const feedback = document.getElementById('email-feedback');
const email = input.value;
const apiKey = 'YOUR_API_KEY'; // <-- Replace with your key
if (!email) {
feedback.textContent = '';
return;
}
feedback.textContent = 'Verifying...';
feedback.style.color = 'gray';
const url = `https://hub.juheapi.com/email_verify/v1/verify?key=${apiKey}&email=${encodeURIComponent(email)}`;
try {
const response = await fetch(url);
const result = await response.json();
const data = result.data;
if (data.is_deliverable) {
feedback.textContent = 'Email is valid!';
feedback.style.color = 'green';
} else {
if (data.did_you_mean) {
feedback.innerHTML = `Invalid. Did you mean <a href="#" onclick="useSuggestion('${data.did_you_mean}')">${data.did_you_mean}</a>?`;
feedback.style.color = 'orange';
} else if (data.is_disposable) {
feedback.textContent = 'Please use a permanent email address.';
feedback.style.color = 'red';
} else {
feedback.textContent = 'This email address does not appear to be valid.';
feedback.style.color = 'red';
}
}
} catch (error) {
console.error('Validation error:', error);
feedback.textContent = 'Could not verify email.';
feedback.style.color = 'red';
}
}
function useSuggestion(suggestion) {
document.getElementById('email').value = suggestion;
validateEmail();
}
</script>
Recipe 2: Batch Cleaning a List (Python)
This script reads a list of emails from a CSV file, verifies each one, and writes the clean results to a new file.
import requests
import csv
API_KEY = 'YOUR_API_KEY' # <-- Replace with your key
API_URL = 'https://hub.juheapi.com/email_verify/v1/verify'
INPUT_FILE = 'email_list.csv'
OUTPUT_FILE = 'email_list_cleaned.csv'
def verify_email(email):
params = {'key': API_KEY, 'email': email}
try:
response = requests.get(API_URL, params=params, timeout=10)
response.raise_for_status()
return response.json().get('data', {})
except requests.exceptions.RequestException as e:
print(f"Error verifying {email}: {e}")
return None
# Assuming input CSV has a column named 'email'
with open(INPUT_FILE, mode='r', newline='') as infile, \
open(OUTPUT_FILE, mode='w', newline='') as outfile:
reader = csv.DictReader(infile)
# Define headers for the output file
fieldnames = reader.fieldnames + ['is_deliverable', 'score', 'is_disposable']
writer = csv.DictWriter(outfile, fieldnames=fieldnames)
writer.writeheader()
for row in reader:
email_to_check = row.get('email')
if email_to_check:
result = verify_email(email_to_check)
if result:
# Add verification data to the row
row['is_deliverable'] = result.get('is_deliverable')
row['score'] = result.get('score')
row['is_disposable'] = result.get('is_disposable')
writer.writerow(row)
print(f"Cleaning complete. Results saved to {OUTPUT_FILE}")
Step 4: Interpreting the Results for Bulletproof Logic
For robust application logic, go beyond a simple check of is_deliverable
. Consider creating rules based on your use case. For instance:
- User Sign-up: Require
is_deliverable === true
ANDis_disposable === false
. - B2B Lead Form: You might require
is_role_account === false
to ensure you get a personal contact. - Marketing List Import: You might accept emails where
is_catch_all === true
but flag them for monitoring, as their deliverability can be less certain.
Conclusion
You've now seen how to build smarter forms and maintain healthier data with just a few lines of code. Integrating a powerful email verification API is a simple step that pays huge dividends in application quality, user experience, and data integrity.
Explore the full API Documentation to see every data point, or check out our other Identity APIs on hub.juheapi.com.