JavaScript Quick Start


Get an API Key and Secret


If you haven’t already, sign up for a free trial.

Include the PasswordPing Library


Use npm to install the PasswordPing package in your project:

npm install passwordping

Try Out Our Example Code


We’ve made calling the API dead simple. This sample code snippet shows you examples of calling the four supported APIs:

var PasswordPing = require('passwordping');

// Create a new PasswordPing instance - this is our primary interface for making API calls
var passwordping = new PasswordPing(YOUR_API_KEY, YOUR_API_SECRET);

// Check whether a password has been compromised
passwordping.checkPassword('password-to-test', function (error, passwordCompromised) {
    if (error) {
        console.log('Error calling API: ' + error);
    }
    else if (passwordCompromised === true) {
        console.log('Password is compromised');
    }
    else {
        console.log('Password is not compromised');
    }
});

// Check whether a specific set of credentials are compromised
passwordping.checkCredentials('test@passwordping.com', 'password-to-test', function (error, credsCompromised) {
    if (error) {
        console.log('Error calling API: ' + error);
    }
    else if (credsCompromised === true) {
        console.log('Credentials are compromised');
    }
    else {
        console.log('Credentials are not compromised');
    }
});

// get all exposures for the given user
passwordping.getExposuresForUser('test@passwordping.com', function(error, result) {
    if (error) {
        console.log('Error calling API: ' + error);
    }
    else {
        console.log(exposures.count + ' exposures found for test@passwordping.com');

        // now get the full details for the first exposure returned in the list
        passwordping.getExposureDetails(result.exposures[0], function(error, exposureDetails) {
            if (error) {
                console.log('Error calling API: ' + error);
            }
            else {
                console.log('First exposure for test@passwordping.com was ' + exposureDetails.title);
            }
        });
    }
});

Learn More


That should get you started. Check out the Github project page for more details.