Tutorial: How to Use an API to Verify an Email Address

To use an API for email verification, you would typically send a GET request to the API endpoint. You can do this in JavaScript using the fetch function.

                        
// Specify the base url and parameters
const baseUrl = 'https://api.ValidEmail.net/';
const params = new URLSearchParams({
    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
fetch(`${baseUrl}?${params}`)
    .then(response => response.json())
    .then(data => {
        // Handle the response

        // Print whether the email is valid
        console.log(`Email is valid: ${data.IsValid}`);

        // Print the score
        console.log(`Score: ${data.Score}`);

        // Print the email state
        console.log(`Email State: ${data.State}`);

        // Print the reason
        console.log(`Reason: ${data.Reason}`);

        // Extract additional information about the email
        const additionalInfo = data.EmailAdditionalInfo;
        for (const info of additionalInfo) {
            console.log(`${info.Key}: ${info.Value}`);
        }
    })
    .catch(error => {
        // Handle any errors
        console.error('Error:', error);
    });
                    

Remember to replace 'Email_Address' and 'YOUR_API_KEY' with the actual email address you want to verify and your actual API key.

As always, it's essential to ensure that your API key is handled securely and not exposed in client-side JavaScript. Ideally, requests to the API should be done server-side to keep your API key hidden.