{"id":21297484,"url":"https://github.com/fvdm/nodejs-haveibeenpwned","last_synced_at":"2025-07-11T18:32:28.219Z","repository":{"id":48589737,"uuid":"60630792","full_name":"fvdm/nodejs-haveibeenpwned","owner":"fvdm","description":"API methods for HaveIBeenPwnd.com (unofficial)","archived":false,"fork":false,"pushed_at":"2021-10-22T15:50:54.000Z","size":98,"stargazers_count":17,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-05-30T16:41:52.450Z","etag":null,"topics":["api-client","breaches","haveibeenpwned","infosec","leaks","nodejs","unlicense"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/haveibeenpwned","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fvdm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-07T16:55:56.000Z","updated_at":"2024-01-31T09:02:20.000Z","dependencies_parsed_at":"2022-09-15T21:12:13.719Z","dependency_job_id":null,"html_url":"https://github.com/fvdm/nodejs-haveibeenpwned","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/fvdm/nodejs-haveibeenpwned","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-haveibeenpwned","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-haveibeenpwned/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-haveibeenpwned/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-haveibeenpwned/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fvdm","download_url":"https://codeload.github.com/fvdm/nodejs-haveibeenpwned/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-haveibeenpwned/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262871726,"owners_count":23377367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","breaches","haveibeenpwned","infosec","leaks","nodejs","unlicense"],"created_at":"2024-11-21T14:37:42.354Z","updated_at":"2025-07-11T18:32:27.934Z","avatar_url":"https://github.com/fvdm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# haveibeenpwned\n\nAPI methods for Have I been pwned (unofficial)\n\n[![npm](https://img.shields.io/npm/v/haveibeenpwned.svg?maxAge=3600)](https://github.com/fvdm/nodejs-haveibeenpwned/blob/master/CHANGELOG.md)\n[![Build Status](https://api.travis-ci.com/fvdm/nodejs-haveibeenpwned.svg?branch=master)](https://travis-ci.com/github/fvdm/nodejs-haveibeenpwned)\n[![Coverage Status](https://coveralls.io/repos/github/fvdm/nodejs-haveibeenpwned/badge.svg?branch=master)](https://coveralls.io/github/fvdm/nodejs-haveibeenpwned?branch=master)\n\n\n* [Node.js](https://nodejs.org)\n* [Have I been pwned](https://haveibeenpwned.com)\n* [API documentation](https://haveibeenpwned.com/API/v2)\n\n\n# Example\n\n```js\nconst hibp = require ('haveibeenpwned') ();\n\nhibp.breachedAccount ('foo@bar.com', (err, data) =\u003e {\n  if (err) {\n    return console.log (err);\n  }\n\n  console.log (data);\n});\n```\n\n\n# Installation\n\n`npm i haveibeenpwned`\n\n\n# Configuration\n\nname    | type   | required | default | description\n:-------|:-------|:---------|:--------|:--------------------------\ntimeout | number | no       | 5000    | Request wait timeout in ms\n\n\n```js\nconst pwned = require ('haveibeenpwned') ({\n  timeout: 10000\n});\n```\n\n\n# Have I Been Pwned\n\nBelow are the methods for the main Have I Been Pwned API.\n\nFor simplicity no error handling is included in the callback examples.\nIt's straightforward: when there is a problem `err` is an instance of\n_Error_ and `data` is _undefined_, otherwise `err` is _null_ and\n`data` is set to the result.\n\n\n## .breachedAccount\n\n**( account, [params], callback )**\n\nAll breaches for an account.\n\n\nargument | type     | required | description\n:--------|:---------|:---------|:--------------------------------\naccount  | string   | yes      | Email or username to check\nparams   | object   | no       | Additional parameters to include\ncallback | function | yes      | `function (err, data) {}`\n\n\n```js\nhibp.breachedAccount ('foo@bar.com', yourCallback);\n```\n\n[Example output](https://haveibeenpwned.com/api/v2/breachedaccount/foo@bar.com)\n\n\n## .breaches\n\n**( [params], callback )**\n\nAll breaches in the system.\n\n\nargument | type     | required | description\n:--------|:---------|:---------|:--------------------------------\nparams   | object   | no       | Additional parameters to include\ncallback | function | yes      | `function (err, data) {}`\n\n\n```js\nhibp.breaches (yourCallback);\n```\n\n[Example output](https://haveibeenpwned.com/api/v2/breaches)\n\n\n## .breach\n\n**( name, [params], callback )**\n\nA single breached site.\n\n\nargument | type     | required | description\n:--------|:---------|:---------|:-----------------------------------\nname     | string   | yes      | Site name to check, i.e. `linkedin`\nparams   | object   | no       | Additional parameters to include\ncallback | function | yes      | `function (err, data) {}`\n\n\n```js\nhibp.breach ('Adobe', yourCallback);\n```\n\n[Example output](https://haveibeenpwned.com/api/v2/breach/Adobe)\n\n\n## .pasteAccount\n\n**( account, callback )**\n\nAll pastes for an account.\n\n\nargument | type     | required | description\n:--------|:---------|:---------|:--------------------------\naccount  | string   | yes      | Email or username to check\ncallback | function | yes      | `function (err, data) {}`\n\n\n```js\nhibp.pasteAccount ('foo@bar.com', yourCallback);\n```\n\n[Example output](https://haveibeenpwned.com/api/v2/pasteaccount/foo@bar.com)\n\n\n## .dataclasses\n\n**( callback )**\n\nAll pastes for an account.\n\n\nargument | type     | required | description\n:--------|:---------|:---------|:-------------------------\ncallback | function | yes      | `function (err, data) {}`\n\n\n```js\nhibp.dataclasses (yourCallback);\n```\n\n[Example output](https://haveibeenpwned.com/api/v2/dataclasses)\n\n\n# Pwned Passwords\n\nBelow are the methods for the Pwned Passwords API.\n\n\n## .pwnedpasswords.byPassword\n\n**( password, [hashed], callback )**\n\nCheck if a password was leaked.\nThe `data` is `0` (int) when none were found.\n\n\nargument | type     | default | description\n:--------|:---------|:--------|:---------------------\npassword | string   |         | The password to check\nhashed   | bool     | false   | Is the password already SHA-1 hashed\ncallback | function |         | `(err, data)`\n\n\n\n```js\nhibp.pwnedpasswords.byPassword ('secret', (err, count) =\u003e {\n  if (!count) {\n    console.log ('Great! Password is not found.');\n  } else {\n    console.log ('Oops! Password was found ' + count + ' times!');\n  }\n});\n\n// -\u003e Oops! Password was found 195263 times!\n```\n\n\n## .pwnedpasswords.byRange\n\n**( hash, [sort], callback )**\n\nGet password hashes similar to the first 5 characters of the SHA-1 hash\nprovided. The callback `data` is an *object* where the keys are the\nlowercase hashes and the values are the number of times they were used.\nWhen nothing is found `data` is `0` (int).\n\nA hash longer then 5 characters is truncated before being sent to the API\nand can be in uppercase or lowercase.\n\n\nargument | type     | default | description\n:--------|:---------|:--------|:-----------------------\nhash     | string   |         | The SHA-1 hash to check\nsort     | bool     | false   | Sort by counts in descending order\ncallback | function |         | `(err, data)`\n\n\n### Sorted by key (default)\n\n```js\nhibp.pwnedpasswords.byRange ('abcdef', (err, data) =\u003e {\n  for (sha in data) {\n    console.log ('%s  %i x', sha, data[sha]);\n  }\n});\n```\n\n\n### Sorted by use counts\n\n```js\nhibp.pwnedpasswords.byRange ('abcdef', true, (err, data) =\u003e {\n  const count = Object.keys (data).length;\n  let i = 1;\n\n  console.log ('Found %i matches', count);\n  console.log ('Top 3:');\n\n  for (sha in data) {\n    console.log ('%i  %s  %i x', i, sha, data[sha]);\n\n    // stop after 3\n    if (i === 3) { break; }\n    i++;\n  }\n});\n\n// -\u003e\n// Found 511 matches\n// Top 3:\n// 1  3b8a55c2b3bf42b83e41f0f95a4149043f6  336 x\n// 2  6a7fc410810db77855d9dfe5b94b95196f7  304 x\n// 3  73a1a21a7b13b50536df19fd586abdf3145  193 x\n```\n\n\n# Unicense\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \u003chttp://unlicense.org\u003e\n\n\n# Author\n\n[Franklin](https://fvdm.com)\n| [Buy me a coffee](https://fvdm.com/donating/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvdm%2Fnodejs-haveibeenpwned","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffvdm%2Fnodejs-haveibeenpwned","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvdm%2Fnodejs-haveibeenpwned/lists"}