Skip to main content

How to verify emails via API (with code examples)

Learn how to integrate Hunter’s Email Verifier API into your app using real examples in cURL, Node.js, and Python.

Updated this week

Verifying emails via API helps your team maintain accurate contact lists, reduce bounce rates, and improve deliverability by checking addresses automatically and at scale.

This guide walks you through how to authenticate your requests, verify emails in real time, and handle common errors effectively.

💡 Use the Email Verifier API with your test key (test-api-key) or production key available in your API keys section.


Why use the API for real-time or automated checks

By verifying emails via API, you can ensure your emails reach real, active inboxes while automating the process across your existing workflows.


Here are some common use cases:

  • Validate emails in real time when users sign up or submit forms.

  • Automatically clean large email lists before sending email campaigns.

  • Integrate email verification into your CRM, lead enrichment, or marketing tools.

Key Takeaway: The Email Verifier API allows developers to automate verification and maintain email list hygiene with minimal manual effort.


How to Use the Email Verifier API

The Email Verifier API endpoint verifies whether an email address exists and is safe to send to.

API overview and authentication

The Email Verifier API endpoint is:

GET https://api.hunter.io/v2/email-verifier

Required parameter:

  • email,: the address you want to verify.

Authentication:

Use your API key as a query parameter or in the request header. You can find your API key after logging into your account in the API keys section.

Here is a full example with authentication via a query parameter:

https://api.hunter.io/v2/email-verifier?email=example@company.com&api_key=YOUR_API_KEY

If the request is successful, the API returns a JSON response containing the result of the verification in the data.status field.

Examples: cURL, Node.js, Python

cURL

One simple way to use the API is with cURL, a command line tool that can be used on practically any machine and OS. It's a great way to get started and familiarize with the endpoint before integrating it in more complex code.

Open your terminal or command prompt, and you can directly query the Email Verifier API like this. Don't forget to insert your own API key, and replace the example email address.

curl "https://api.hunter.io/v2/email-verifier?email=example@company.com&api_key=YOUR_API_KEY"

The response will be printed in JSON format directly below in the terminal.

Node.js

Here's a more involved example using Node.js.

const axios = require('axios');

const verifyEmail = async (email) => {
const apiKey = 'YOUR_API_KEY';
const url = `https://api.hunter.io/v2/email-verifier?email=${email}&api_key=${apiKey}`;

try {
const response = await axios.get(url);
console.log(response.data);
} catch (error) {
console.error(error);
}
};

verifyEmail('example@company.com');

To use this code effectively, make sure the module axios is already installed, using the command npm install axios.

Python

Finally, you'll find below a simple example using Python.

import requests

def verifyEmail(email):
api_key = "YOUR_API_KEY"

url = f"https://api.hunter.io/v2/email-verifier?email={email}&api_key={api_key}"
response = requests.get(url)

print(response.json())

verifyEmail("example@company.com")

Make sure you've installed the library requests beforehand, using the command pip install requests in your terminal.


Handling errors and retries

If an error occurs, the API will return an HTTP status code along with a descriptive message in JSON format. Understanding these responses helps you handle errors gracefully and keep your integration stable.

Status

Meaning

Typical Cause

200 OK

Verification succeeded

The request completed successfully and returned a result.

202 Accepted

Temporary issue (e.g., greylisting)

The verification could not be completed immediately and should be retried later.

400 Bad Request

Missing or invalid parameters

The request is incorrectly formatted or is missing the email required field.

401 Unauthorized

Invalid or missing API key

The API key is missing, invalid, expired, or was not recognized.

429 Too Many Requests

Rate limit reached

Too many API calls were made in a short time.

Real-world examples

  • 401 Unauthorized due to truncated API key

    When using curl, forgetting quotation marks around the full URL can cause anything following the & to be truncated, and results in a 401 error.
    Example response:

    {   "errors": [     {       
    "id": "authentication_failed",
    "code": 401,
    "details": "No user found for the API key supplied"
    } ] }

    Fix: Always wrap your request URL in double quotes:

    curl "https://api.hunter.io/v2/email-verifier?email=example@company.com&api_key=YOUR_API_KEY"

  • 202 Accepted due to greylisting

    Sometimes, email servers (like Mimecast) temporarily delay verification requests as a spam prevention measure. This is called greylisting.
    In this case, the API responds with a 202 status code, meaning the verification is pending and should be retried later.

    Fix: Implement a retry mechanism that attempts the request again after a delay, typically within 1 to 12 hours.


Retry and logging best practices

To make your integration resilient and maintain good performance:

  • Implement retry logic for temporary errors (202 or 429) and network timeouts.

  • Use exponential backoff, increasing the delay after each retry (e.g., 1s → 2s → 4s → 8s).

  • Avoid excessive retries, stop after a reasonable number (e.g., 3–5 attempts).

  • Log all error responses for debugging and trend analysis. This helps identify common issues, such as invalid emails or incorrect API usage.

  • Monitor rate limits, the Email Verifier API endpoint is rate limited to 10 requests per second and 300 requests per minute.

Best practices for performance.

To keep your integration efficient and within rate limits, follow these tips:

  • Respect rate limits:
    The Email Verifier API doesn’t support batch requests. Add a short delay (around 200–500 ms) between each call to avoid 429 Too Many Requests errors.

  • Cache results:
    Store verified emails and their statuses to prevent redundant API calls. Most verification results don’t change often, so recheck only after a set period (e.g., every 30 days).

  • Verify only new or updated emails:
    Only send verification requests when an address is added or modified in your database.

  • Use asynchronous or queued processing:
    For larger volumes, manage requests through a queue or background job system to spread them out and maintain consistent throughput.


Best plan in Hunter to verify emails via API

If you regularly verify emails through the API, the Data Platform plan is the most suitable option. These plans include verification credits that you can use flexibly across API calls or bulk uploads.


You can choose the number of credits you need, and they remain valid for 12 months, giving you full control over your usage and pacing. Each Data Platform plan also comes with a dedicated Account Manager, who can help you with setup, optimization, and best practices for large-scale integrations.

💡 Learn more about Data Platform plans on Hunter’s Pricing page.


You'll find more detailed information about the Email Verifier API endpoint in our API documentation.

Did this answer your question?