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 🙏

© 2025 – Pkg Stats / Ryan Hefner

hibp

v15.0.1

Published

An unofficial TypeScript SDK for the 'Have I been pwned?' service.

Downloads

45,644

Readme

hibp

An unofficial TypeScript SDK for Troy Hunt's Have I been pwned? service.

npm Version Build Status Code Coverage All Contributors

Installation

In Node.js:

npm install hibp

In Deno:

// Replace x.y.z with the desired hibp version
import * as hibp from 'npm:hibp@x.y.z';

See the browser section below for information on how to use it in the browser.

Features (🔑 = requires an API key)

  • Get a single breach event
  • Get all breaches for an account 🔑
  • Get all breach events in the system
  • Get all data classes
  • Get all pastes for an account 🔑
  • Securely check a password to see if it has been exposed in a data breach
  • Check a SHA-1 or NTLM prefix to see if it has been exposed in a data breach
  • Search for an account in both breaches and pastes at the same time 🔑
  • Get your subscription status 🔑
  • All queries return a Promise
  • Available server-side (e.g., Node.js) and client-side (browser)
  • Written in TypeScript, so all modules come fully typed

Usage

// import individual modules as needed
import { dataClasses, search } from 'hibp';

// or, import all modules into a local namespace
import * as hibp from 'hibp';

The following modules are available:

Please see the API reference for more detailed usage information and examples.

Quick-Start Example

import { search } from 'hibp';

async function main() {
  try {
    const data = await search('someAccountOrEmail', { apiKey: 'my-api-key' });
    if (data.breaches || data.pastes) {
      // Bummer...
      console.log(data);
    } else {
      // Phew! We're clear.
      console.log('Good news — no pwnage found!');
    }
  } catch (err) {
    // Something went wrong.
    console.log(err.message);
  }
}

void main();

Rate Limiting

The haveibeenpwned.com API rate limits requests to prevent abuse. In the event you get rate limited, the module will throw a custom RateLimitError which will include a retryAfterSeconds property so you know when you can try the call again (as a number, unless the remote API did not provide one, in which case it will be undefined - but that should never happen).

Using in the browser

You have a couple of options for using this library in a browser environment:

  1. Bundled

    The most efficient and recommended method is to bundle it with client-side code using a module bundler, most likely dictated by your web application framework of choice.

  2. ESM for Browsers

    Alternatively, you can also import the library directly in your HTML via <script type="module"> tags in modern browsers. The pre-bundled module is available through the unpkg CDN, but you must specify the full path (including the file extension). It's also strongly recommended to include the exact version number as well, otherwise the latest tag will be used, which could be dangerous if/when there are breaking changes made to the API. See unpkg for details and advanced version specification, but you will probably want to do the following (replacing x.y.z with the version you want):

    <script type="module">
      // Replace x.y.z with the desired hibp version      ↓ ↓ ↓
      import { dataClasses } from 'https://unpkg.com/hibp@x.y.z/dist/browser/hibp.module.js';
    
      const logDataClasses = async () => {
        console.table(await dataClasses());
      };
    
      logDataClasses();
    </script>

    For more information on ESM in the browser, check out Using JS modules in the browser.

Try It Out

Test hibp in your browser with StackBlitz.

Projects Using hibp

Send me a PR or an email and I'll add yours to the list!

License

This module is distributed under the MIT License.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!