Giter Site home page Giter Site logo

verifalia-node-sdk's Introduction

Verifalia REST API - SDK and helper library for Node.js

Verifalia provides a simple HTTPS-based API for validating email addresses and checking whether they are deliverable or not. Learn more at http://verifalia.com

Adding Verifalia REST API support to your Node.js project

The easiest way to add support for the Verifalia REST API to your Node.js project is to use npm, which will automatically download and install the required files. With npm installed, run the following from your project root:

$ npm install verifalia

Validate an email address

The example below shows how to have your Node.js application to submit and validate a couple of email addresses using the Verifalia helper library for Node.js:

// Initializes and configures the Verifalia SDK, using your sub-account SID and auth
// token. Sub-accounts can be managed through the Verifalia dashboard, in the
// clients area.

var verifalia = require('verifalia')
	.client('YOUR-ACCOUNT-SID', 'YOUR-AUTH-TOKEN');

// Submits the email address to Verifalia

verifalia
	.emailValidations
	.submit('[email protected]',
	{
		// The callback function is called at the completion of the validation
	
		callback: (error, data) => {
			// Displays the validation results
			
			console.log(data);
		},
		
		// Waits untile the engine completes the validation
		
		waitForCompletion: true
	});

Validate a list of email addresses

The submit() function accepts a single email address, as shown above, or an array of email addresses to validate in the same batch. In this case, just pass an array of strings instead of the single value:

// ...

verifalia
	.emailValidations
	.submit([ '[email protected]', '[email protected]' ],
	{
		callback: (error, data) => {

// ...

Submit a validation without waiting for its completion

Internally, the submit() function sends the email addresses to the Verifalia servers and then polls them until the validations complete. Instead of relying on this automatic polling behavior, you may even manually query the Verifalia servers by way of the query() function. In that case, you can submit the email addresses without waiting for their completion, as shown below:

// Submits an email address to Verifalia and returns without waiting for the
// completion of the batch.

verifalia
	.emailValidations
	.submit('[email protected]',

	// Since we don't want to wait for the completion of the batch, we can just
	// pass a callback here:

	(error, data) => {
		// Displays the uniqueID of the batch, which can be used to later
		// retrieve the results from Verifalia.
		
		if (data.status == verifalia.emailValidations.VALIDATION_STATUS_COMPLETED) {
			// The batch has been completed in a single submit() call
		
			console.log(data);
			return;
		}
		
		// TODO: Schedule a retrieval of the results, by way of the query() function
		
		console.log(data.uniqueID);
	});

Retrieve the Submit a validation without waiting for its completion

To retrieve the results of a batch you have submitted as shown above, you can pass the uniqueID of your batch to the query() function, optionally waiting until the job completes:

// Retrieves the results of a batch from Verifalia and waits for its completion

verifalia
	.emailValidations
	.query(data.uniqueID, // Assumes we have data.uniqueID from the previous sample
	{
		// The callback function is called at the completion of the validation
	
		callback: (error, data) => {
			// Displays the validation results
			
			console.log(data);
		},
		waitForCompletion: true
	});

The query() function shares the same semantic of submit(), so you can avoid waiting for the completion of the job here as well.

Delete a batch and its results

Verifalia automatically deletes the lists of email addresses you submit and their results after 30 days since their validation. For security purposes, you can force the immediate removal of a batch by way of the delete() function, as shown below:

// Deletes a batch, given its uniqueID

verifalia
	.emailValidations
	.delete(data.uniqueID); // Assumes we have data.uniqueID from the previous sample

License

MIT

Support

Request help and support at verifalia.com/support/contact-us.

verifalia-node-sdk's People

Contributors

verifalia avatar

Watchers

James Cloos avatar seek fine art avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.