npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clearbit

v1.3.5

Published

Client for Clearbit.co business intelligence APIs

Downloads

300,270

Readme

clearbit-node Build Status Code Climate Test Coverage

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

Setup

$ npm install clearbit
var 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

  • email String: The email address to look up (required)
  • webhook_id String: Custom identifier for the webhook request
  • subscribe Boolean: Set to true to subscribe to the changes
  • stream Boolean: Set to true to use the streaming API instead of webhooks
  • timeout Integer: The timeout in milliseconds after which a socket closed error will be thrown.
var Person = clearbit.Person;
Person.find({email: '[email protected]'})
  .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

  • domain String: The company domain to look up (required)
  • webhook_id String: Custom identifier for the webhook request
  • stream Boolean: Set to true to use the streaming API instead of webhooks
  • timeout Integer: The timeout in milliseconds after which a socket closed error will be thrown.
var Company = 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

  • name String: The company name to look up (required)
  • timeout Integer: The timeout in milliseconds after which a socket closed error will be thrown.
var NameToDomain = 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

  • domain String: The domain to search for. (required)
  • role String: Employment role to filter by.
  • roles Array[String]: Employment roles to filter by.
  • seniority String: Employment seniority to filter by.
  • seniorities Array[String]: Employment seniorities to filter by.
  • title String: Job title to filter by.
  • titles Array[String]: Job titles to filter by.
  • city String: City to filter by.
  • cities Array[String]: Cities to filter by.
  • state String: State to filter by.
  • states Array[String]: States to filter by.
  • country String: Country to filter by.
  • countries Array[String]: Countries to filter by.
  • name String: Name of an individual to filter by.
  • page Integer: The page of results to fetch.
  • page_size Integer: The number of results per page.
  • suppression String: 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.
var Prospector = 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: '[email protected]'})
  .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 protected]'}).nodeify(function (err, person) {
  if (err) {
    // handle
  }
  else {
    // person
  }
});