Using an API for email verification involves sending a GET request to the API endpoint. Here's how you can do this using Python:
import requests
# specify the base url and parameters
base_url = 'https://api.ValidEmail.net/'
params = {
'email': 'Email_Address', # replace with the email you want to verify
'token': 'YOUR_API_KEY' # replace with your actual API key
}
# make the GET request
response = requests.get(base_url, params=params)
# handle the response
if response.status_code == 200:
data = response.json()
# Extract specific information from the response
is_valid = data['IsValid']
score = data['Score']
email_state = data['State']
reason = data['Reason']
print(f"Email is valid: {is_valid}")
print(f"Score: {score}")
print(f"Email State: {email_state}")
print(f"Reason: {reason}")
# Extract additional information about the email
additional_info = data['EmailAdditionalInfo']
for info in additional_info:
print(f"{info['Key']}: {info['Value']}")
else:
print(f"Request failed with status {response.status_code}")
Remember to replace 'Email_Address' and 'YOUR_API_KEY' with the actual email address you want to verify and your actual API key.
In this script, we first check if the request was successful by comparing response.status_code to 200. If the request was successful, we then parse the response data.