ZeroBounce Email Verification Library for TS
Getting Started
You will need a zerobounce account to get started.
Once you get an account, you will need to get an api key
to use it in the API calls.
Installation
Require the package
$ npm install zerobounce
Usage
import { Api } from 'zerobounce';
const credits = async (api: Api) => {
try {
const response = await api.getCredits();
if (response.isSuccess()) {
console.log('you have', response.success?.credits, 'credits left');
} else if (response.isError()) {
console.log('the api returned following error', response.error?.error);
}
} catch (error) {
console.log('unable to fetch data from server', error);
}
}
const validate = async (api: Api, email: string, ipAddress: string | null = null) => {
try {
const response = await api.validate(email, ipAddress)
if (response.isSuccess()) {
console.log('the email address', email, 'is', response.success?.status);
} else if (response.isError()) {
console.log('the api returned following error', response.error?.error);
}
} catch (error) {
console.log('unable to fetch data from server', error);
}
}
const api = new Api('your-api-key');
validate(api, 'valid@example.com');
validate(api, 'invalid@example.com');
validate(api, 'valid@example.com', '127.0.0.1');
credits(api);
License
MIT
Test
Set your api key in the ZEROBOUNCE_API_KEY
environment variable, then run:
$ npm test
Bug Reports
Report here.