Skip to content

Repository files navigation

⚠️ DEPRECATION WARNING

This package is no longer being maintained. If you're looking to integrate with Clearbit's API we recommend looking at the HTTP requests available in our documentation at clearbit.com/docs

clearbit-node Build StatusCode ClimateTest Coverage

Node library for querying the Clearbit business intelligence APIs. Currently supports:

Setup

$ npm install clearbit
varclearbit=require('clearbit')('api_key');// orvarClient=require('clearbit').Client;varclearbit=newClient({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 request
  • subscribeBoolean: Set to true to subscribe to the changes
  • streamBoolean: Set to true to use the streaming API instead of webhooks
  • timeoutInteger: The timeout in milliseconds after which a socket closed error will be thrown.
varPerson=clearbit.Person;Person.find({email: 'email@domain.com'}).then(function(person){console.log('Name: ',person.name.fullName);}).catch(Person.QueuedError,function(err){console.log(err);// Person is queued}).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');});

Company

Company.find(options) -> Promise

  • domainString: The company domain to look up (required)
  • webhook_idString: Custom identifier for the webhook request
  • streamBoolean: Set to true to use the streaming API instead of webhooks
  • timeoutInteger: The timeout in milliseconds after which a socket closed error will be thrown.
varCompany=clearbit.Company;Company.find({domain: 'www.uber.com'}).then(function(company){console.log('Name: ',company.name);}).catch(Company.QueuedError,function(err){console.log(err);// Company is queued}).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');});

NameToDomain

NameToDomain.find(options) -> Promise

  • nameString: The company name to look up (required)
  • timeoutInteger: The timeout in milliseconds after which a socket closed error will be thrown.
varNameToDomain=clearbit.NameToDomain;NameToDomain.find({name: 'Uber'}).then(function(result){console.log('Domain: ',result.domain);}).catch(NameToDomain.NotFoundError,function(err){console.log(err);// Domain could not be found}).catch(function(err){console.log('Bad/invalid request, unauthorized, Clearbit error, or failed request');});

Prospector

Prospector.search(options) -> Promise

  • domainString: The domain to search for. (required)
  • roleString: Employment role to filter by.
  • rolesArray[String]: Employment roles to filter by.
  • seniorityString: Employment seniority to filter by.
  • senioritiesArray[String]: Employment seniorities to filter by.
  • titleString: Job title to filter by.
  • titlesArray[String]: Job titles to filter by.
  • cityString: City to filter by.
  • citiesArray[String]: Cities to filter by.
  • stateString: State to filter by.
  • statesArray[String]: States to filter by.
  • countryString: Country to filter by.
  • countriesArray[String]: Countries to filter by.
  • nameString: Name of an individual to filter by.
  • pageInteger: The page of results to fetch.
  • page_sizeInteger: The number of results per page.
  • suppressionString: Set to eu to exclude records with country data in the EU. Set to eu_strict to exclude records with country data in the EU or with null country data.
varProspector=clearbit.Prospector;Prospector.search({domain: 'clearbit.com'}).then(function(result){console.log('Results: ',result.results);}).catch(function(err){console.log('Bad/invalid request, unauthorized, Clearbit error, or failed request');});

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}});

About

Node library for querying the Clearbit business intelligence APIs

Resources

Stars

71 stars

Watchers

36 watching

Forks

Releases

Packages

Used by

Contributors

Languages