What is token, and why should I use it?
The token is used to provide time-limited access to Emaildate service in a safe way that will not compromise your API key.
The token can be fetched from the Emalidate server using the GET request in the following format:
https://api.emalidate.com/token/?apikey=<YOUR_API_KEY>
Optionally, the request can include the parameter "duration" to define the token validity period in seconds:
https://api.emalidate.com/token/?apikey=<YOUR_API_KEY>&duration=<VALIDITY_PERIOD_IN_SECONDS>
If this parameter is not supplied, the default value of 300 seconds will be applied.
Parameters:
apikey - your emalidate API key
duration - token validity period in seconds
Please note that setting the duration parameter too high makes no sense because when used on the front-end (which is the primary purpose of the token) it can be stolen and abused.
Generating tokens costs one credit per request.
When using Emalidate service on the front-end, we strongly recommend using the Authorization token instead of an API key, since the API key, in this case, can be stolen and abused.
Unlike the API key that does not expire (API key is valid until you change its value through Emalidate dashboard), token has set an expiration date and time and even if it gets stolen it can not be used after it is expired. Therefore it is recommended to use short validity period for Emalidate token.
CURL example:
$ curl https://api.emalidate.com/token?apikey=8f7b********************************3cba
Result:
{
"error": 0,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJlbWFsaWRhdGUuY29tIiwic3ViIjoiMWY5YzNhNjRkNjNmZWNiNDEwNGQ1MTc4ZDIyNGY4ODEzYjUzMGQwZiIsImlhdCI6MTY2MjM4Mzc4NiwiZXhwIjoxNjYyMzg0MDg2LCJqdGkiOiIxZjljM2E2NGQ2M2ZlY2I0MTA0ZDUxNzhkMjI0Zjg4MTNiNTMwZDBmZWR0NmI1bjlvZWgiLCJraWQiOiIxY2I2MDlkZTUyMDBlYjNmZTgxZWQyMDRiZjllNDBkZCJ9.fI67W8LcyGa4_F4q2JG7bl-FyenOMUo2PgttnCjaRhk",
"pointsUsed": 1,
"pointsAvailable": 1998
}
This command validates the email format and returns the information about the mail domain.
Format:
https://api.emalidate.com/validate?email=<EMAIL_ADDRESS_TO_CHECK>&apikey=<YOUR_API_KEY>
Parameters:
apikey - your emalidate API key
email - email address to be verified
Example:
https://api.emalidate.com/validate?email=info@emalidate.com&apikey=<YOUR_API_KEY>
CURL example (with token):
$ curl --oauth2-bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJlbWFsaWRhdGUuY29tIiwic3ViIjoiPFlPVVJfVVNFUl9JRD4iLCJpYXQiOjE2NjA1NTMxMDEsImV4cCI6MTY2MDU1MzQwMSwianRpIjoiSzIzNF9KV1RfRU1MRFQiLCJraWQiOiJzb01lX2FwaV9rZXlfaWQifQ.WdonEWw_A7Zi6zE-wRdKfARGDoopGyzfrSfITCkAMQg https://api.emalidate.com/validate?email=info@emalidate.com
Result:
{
"error": 0,
"email": "info@emalidate.com",
"commandRequested": "validate",
"commandExecuted": "validate",
"checkCatchAll": false,
"isValidated": true,
"isVerified": false,
"domainExists": true,
"hasMX": true,
"isCatchall": null,
"pointsUsed": 2,
"pointsAvailable": 1968,
"time": "0.022 seconds",
"provider": "Other",
"mxRecords": [
{
"exchange": "mail.emalidate.com",
"priority": 10
}
],
"isFree": false,
"isDisposable": false
}
After validating the format of the email address (same as the "validate" command) this command attempts to deliver a message to it and returns the result of that operation including all the information about the mail domain.
Format:
https://api.emalidate.com/verify?email=<EMAIL_ADDRESS_TO_CHECK>&apikey=<YOUR_API_KEY>&cca=<CHECK_CATCH_ALL 0||1>
Parameters:
apikey - your emalidate API key
email - email address to be verified
cca - flag that defines whether or not emalidate will check if the domain has the "catch all" address (an email account that accepts any email address on a particular domain)
Example:
https://api.emalidate.com/verify?email=confirm@emalidate.com&apikey=<YOUR_API_KEY>&cca=1
CURL example (with token):
$ curl --oauth2-bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJlbWFsaWRhdGUuY29tIiwic3ViIjoiPFlPVVJfVVNFUl9JRD4iLCJpYXQiOjE2NjA1NTMxMDEsImV4cCI6MTY2MDU1MzQwMSwianRpIjoiSzIzNF9KV1RfRU1MRFQiLCJraWQiOiJzb01lX2FwaV9rZXlfaWQifQ.WdonEWw_A7Zi6zE-wRdKfARGDoopGyzfrSfITCkAMQg "https://api.emalidate.com/verify?email=confirm@emalidate.com&cca=1"
Result:
{
"error": 0,
"email": "confirm@emalidate.com",
"commandRequested": "verify",
"commandExecuted": "verify",
"checkCatchAll": true,
"isValidated": true,
"isVerified": true,
"domainExists": true,
"hasMX": true,
"isCatchall": false,
"pointsUsed": 4,
"pointsAvailable": 1954,
"time": "0.059 seconds",
"provider": "Other",
"mxRecords": [
{
"exchange": "mail.emalidate.com",
"priority": 10
}
],
"isFree": false,
"isDisposable": false,
"mxServer": "mail.emalidate.com",
"code": 250,
"desc": "REQUESTED MAIL ACTION OKAY COMPLETED"
}
<!DOCTYPE HTML>
<html>
<body>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
var token = `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJpc3MiOiJlbWFsaWRhdGUuY29tIiwic3ViIjoiPFlPVVJfVVNFUl9JRD4iLCJpYXQiOjE2NjA1NTMxMDEsImV4cCI6MTY2MDU1MzQwMSwianRpIjoiSzIzNF9KV1RfRU1MRFQiLCJraWQiOiJzb01lX2FwaV9rZXlfaWQifQ.
WdonEWw_A7Zi6zE-wRdKfARGDoopGyzfrSfITCkAMQg`;
// token variable should be replaced with the valid token, preferrably generated in the background
async function checkEmail(email, cmd = "validate", cca = 0) {
if (cmd != "validate" && cmd != "verify") return false;
var settings = {
cache: false,
async: true,
crossDomain: true,
url: "https://api.emalidate.com/" + cmd + "?email=" + encodeURIComponent(email) + "&cca=" + cca,
method: "GET",
headers: {
accept: "application/json",
'Access-Control-Allow-Origin': "*",
Authorization: "Bearer " + token
},
success: function (data) {
return data;
}
}
return await $.ajax(settings);
}
$(function () {
$(".emlButton").click(async function () {
var cmd = $(this).prop("id");
var email = $("#email").val();
if (!email) return false;
$(".emlButton").prop("disabled", true);
if (cmd == "verify") {
cca = $("#cca").prop("checked") ? 1 : 0;
} else {
cca = 0;
}
var result = await checkEmail(email, cmd, cca);
console.log(result);
$("#displayResult").val(JSON.stringify(result, null, 2));
$(".emlButton").prop("disabled", false);
});
});
</script>
<input type="text" placeholder="Enter email address you want to check" id="email" size="50" /><br /><input
type="checkbox" name="cca" id="cca" value="1" /> Check "Catch all"<br />
<button id="validate" class="emlButton">Validate</button><button id="verify" class="emlButton">Verify</button><br />
<textarea id="displayResult" cols="80" rows="15"></textarea>
</body>
</html>