|
| 1 | +# AbstractAPI javascript-email-validation library |
| 2 | + |
| 3 | +Integrate the powerful [email validation API from Abstract](https://www.abstractapi.com/email-verification-validation-api) in your Javascript or NodeJS project in a few lines of code. |
| 4 | + |
| 5 | +Abstract's Email Validation and Verification API is a fast, lightweight, modern, and RESTful JSON API for determining the validity and other details of email addresses. |
| 6 | + |
| 7 | +It's very simple to use: you only need to submit your API key and an email address, and the API will respond an assessment of its validity, as well as additional details like quality score if it's a disposable email, a catchall address, and more. |
| 8 | + |
| 9 | +Validating and verifying email addresses is a critical step to reducing the chances of low-quality data and fraudulent or risky users in your website or application. |
| 10 | + |
| 11 | +# Documentation |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +You can install **javascript-email-validation** via npm, from our CDN, or download the source into your project. |
| 16 | + |
| 17 | +### ES6 |
| 18 | + |
| 19 | +Download and install the library from npm: |
| 20 | + |
| 21 | +``` |
| 22 | +npm install javascript-email-validation --save |
| 23 | +``` |
| 24 | + |
| 25 | +In your project, import it and configure your `API_KEY`: |
| 26 | + |
| 27 | +```js |
| 28 | +import {AbstractEmailValidation} from 'javascript-email-validation' |
| 29 | + |
| 30 | +AbstractEmailValidation.configure('API_KEY') |
| 31 | +``` |
| 32 | + |
| 33 | +### Browser, from the built file |
| 34 | + |
| 35 | +You can build the library yourself, or get the already built file from the `dist` directory and load it: |
| 36 | + |
| 37 | +```js |
| 38 | +<script src="dist/javascript-email-validation.js"></script> |
| 39 | +<script> |
| 40 | + AbstractEmailValidation.configure('API_KEY'); |
| 41 | + |
| 42 | + // use the library |
| 43 | +</script> |
| 44 | +``` |
| 45 | + |
| 46 | +## API key |
| 47 | + |
| 48 | +Get your API key for free and without hassle from the [Abstact website](https://app.abstractapi.com/users/signup?target=/api/email-validation/pricing/select). |
| 49 | + |
| 50 | +## Quickstart |
| 51 | + |
| 52 | +AbstractAPI **javascript-email-validation** library returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) so you can use one of the following approaches: |
| 53 | + |
| 54 | +### Async/Await |
| 55 | + |
| 56 | +```js |
| 57 | +async function validateEmail(email) { |
| 58 | + let response = await AbstractEmailValidation.verify(email); |
| 59 | + console.log(response); |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +### Using .then() |
| 64 | + |
| 65 | +```js |
| 66 | +function validateEmail(email) { |
| 67 | + AbstractEmailValidation.verify(email) |
| 68 | + .then(response => { |
| 69 | + console.log(response); |
| 70 | + }) |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +## API response |
| 75 | + |
| 76 | +The API response contains the following fields: |
| 77 | + |
| 78 | +| PARAMETER | TYPE | DETAILS | |
| 79 | +| - | - | - | |
| 80 | +| email | String | The value for "email" that was entered into the request. | |
| 81 | +| auto_correct | String | If a typo has been detected then this parameter returns a suggestion of the correct email (e.g., johnsmith@gmial.com => johnsmith@gmail.com). If no typo is detected then this is empty. | |
| 82 | +| deliverability | String | Abstract's evaluation of the deliverability of the email. Possible values are: DELIVERABLE, UNDELIVERABLE, RISKY, and UNKNOWN | |
| 83 | +| quality_score | Number | An internal decimal score between 0.01 and 0.99 reflecting Abstract's confidence in the quality and deliverability of the submitted email. | |
| 84 | +| is_valid_format | Boolean | Is true if the email follows the format of "address @ domain . TLD". If any of those elements are missing or if they contain extra or incorrect special characters, then it returns false. | |
| 85 | +| is_free_email | Boolean | Is true if the email's domain is found among Abstract's list of free email providers (e.g., Gmail, Yahoo, etc). | |
| 86 | +| is_disposable_email | Boolean | Is true if the email's domain is found among Abstract's list of disposable email providers (e.g., Mailinator, Yopmail, etc). | |
| 87 | +| is_role_email | Boolean | Is true if the email's local part (e.g., the "to" part) appears to be for a role rather than individual. Examples of this include "team@", "sales@", info@", etc. | |
| 88 | +| is_catchall_email | Boolean | Is true if the domain is configured to catch all email. | |
| 89 | +| is_mx_found | Boolean | Is true if MX Records for the domain can be found. Only available on paid plans. Will return null and UNKNOWN on free plans. | |
| 90 | +| is_smtp_valid | Boolean | Is true is the SMTP check of the domain was successful. Only available on paid plans. Will return null and UNKNOWN on free plans. | |
| 91 | + |
| 92 | +## Detailed documentation |
| 93 | + |
| 94 | +You will find additional information and request examples in the [Abstract help page](https://app.abstractapi.com/api/email-validation/documentation). |
| 95 | + |
| 96 | +## Getting help |
| 97 | + |
| 98 | +If you need help installing or using the library, please contact [Abstract's Support](https://app.abstractapi.com/api/email-validation/support). |
| 99 | + |
| 100 | +For bug report and feature suggestion, please use [this repository issues page](https://github.com/abstractapi/javascript-email-validation/issues). |
| 101 | + |
| 102 | +# Contribution |
| 103 | + |
| 104 | +Contributions are always welcome, as they improve the quality of the libraries we provide to the community. |
| 105 | + |
| 106 | +Please provide your changes covered by the appropriate unit tests, and post them in the [pull requests page](https://github.com/abstractapi/javascript-email-validation/pulls). |
| 107 | + |
| 108 | +## NPM |
| 109 | + |
| 110 | +### Installation |
| 111 | + |
| 112 | +Run `npm install` in the command line to install the dependencies. To update those dependencies you need to run `npm update`. |
| 113 | + |
| 114 | +### Building |
| 115 | + |
| 116 | +To build the library and generate the minified file in the *dist* directory, you need to run `npm run build`. |
| 117 | + |
| 118 | +To build the lib, you need to run `npm run build:lib`. |
| 119 | + |
| 120 | +### Test |
| 121 | + |
| 122 | +To run the test suite, you need to run: `npm run test`. |
| 123 | + |
0 commit comments