Package Exports
- clearbit
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (clearbit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
clearbit-node

Node library for querying the Clearbit business intelligence APIs. Currently supports:
Setup
$ npm install clearbitvar clearbit = require('clearbit')('api_key');
// or
var Client = require('clearbit').Client;
var clearbit = new Client({key: 'api_key'});Performing Lookups
Person
Person.find(options) -> Promise
emailString: The email address to look up (required)webhook_idString: Custom identifier for the webhook requestsubscribeBoolean: Set totrueto subscribe to the changescompanyBoolean: Set totrueto include a company lookup on the email’s domain name in the responsestreamBoolean: Set totrueto use the streaming API instead of webhooks
var Person = clearbit.Person;
Person.find({email: 'email@domain.com'})
.then(function (person) {
if (!person.pending()) {
console.log('Name: ', person.name.fullName);
}
})
.catch(Person.NotFoundError, function (err) {
console.log(err); // Person could not be found
})
.catch(function (err) {
console.log('Bad/invalid request, unauthorized, Clearbit error, or failed request');
});person.pending() -> Boolean
If Clearbit responds with a 202 status indicating that lookup has been queued, person.pending returns true.
Company
Company.find(options) -> Promise
domainString: The company domain to look up (required)webhook_idString: Custom identifier for the webhook requeststreamBoolean: Set totrueto use the streaming API instead of webhooks
var Company = clearbit.Company;
Company.find({domain: 'www.uber.com'})
.then(function (company) {
if (!company.pending()) {
console.log('Name: ', company.name);
}
})
.catch(Company.NotFoundError, function (err) {
console.log(err); // Company could not be found
})
.catch(function (err) {
console.log('Bad/invalid request, unauthorized, Clearbit error, or failed request');
});company.pending() -> Boolean
If Clearbit responds with a 202 status indicating that lookup has been queued, company.pending returns true.
Error Handling
Lookups return Bluebird promises. Any status code >=400 will trigger an error, including lookups than do not return a result. You can easily filter out unknown records from true errors using Bluebird's error class matching:
Person.find({email: 'notfound@example.com'})
.catch(Person.NotFoundError, function () {
// handle an unknown record
})
.catch(function () {
// handle other errors
});Callbacks
If you really want to use node-style callbacks, use Bluebird's nodeify method:
Person.find({email: 'email@domain.com'}).nodeify(function (err, person) {
if (err) {
// handle
}
else {
// person
}
});