API Directory › 🛠️ Developer Tools › Have I Been Pwned
API KeyHTTPSCORS

Have I Been Pwned API

Check if an email or password appeared in known data breaches.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open Have I Been Pwned docs ↗

What it does

Have I Been Pwned (HIBP) lets you check whether an email address or password has appeared in a known data breach. The account APIs need a key; the Pwned Passwords range API is free, key-less and uses k-anonymity so you never send a full password or its full hash.

Base URL

https://haveibeenpwned.com/api/v3

Authentication

Breach/account endpoints require an hibp-api-key header from a paid subscription (tiers differ by rate limit). Every request must also set a descriptive User-Agent. Pwned Passwords (https://api.pwnedpasswords.com/range/{prefix}) needs neither.

Code examples

curl (Pwned Passwords, no key)
# SHA-1 of "P@ssw0rd" = 21BD1...; send only the first 5 hex chars
curl https://api.pwnedpasswords.com/range/21BD1
Python (k-anonymity password check)
import hashlib, requests

def pwned_count(pw):
    h = hashlib.sha1(pw.encode()).hexdigest().upper()
    prefix, suffix = h[:5], h[5:]
    r = requests.get(f"https://api.pwnedpasswords.com/range/{prefix}", timeout=10)
    for line in r.text.splitlines():
        s, count = line.split(":")
        if s == suffix:
            return int(count)
    return 0

print(pwned_count("password"))  # a very large number

Rate limits & quotas

Pwned Passwords: effectively unlimited, cache-friendly (CDN-backed), add ?mode=ntlm or the Add-Padding: true header to hide response size. Account APIs: rate limited by subscription tier (e.g. 10 requests/minute on the entry plan), returning HTTP 429 with Retry-After when exceeded.

Key response fields

(range response)Lines of HASH_SUFFIX:COUNT — match your suffix to get the breach count
Name / Title / BreachDateBreach metadata from /breachedaccount
DataClasses[]What was exposed (Emails, Passwords, Phone numbers…)
IsVerified / IsSensitiveWhether the breach is confirmed / sensitive

Common errors

401Missing or invalid hibp-api-key on an account endpoint.
403Missing User-Agent header — it is mandatory.
404Account not found in any breach (this is the ‘good’ answer).
429Rate limit exceeded — wait Retry-After seconds.

When to use it (and alternatives)

Use Pwned Passwords to block compromised passwords at sign-up or password-change — it is free and privacy-preserving. Use the paid breach API for security dashboards and user notifications. Never send a raw password anywhere; the range API exists precisely so you don’t have to.

FAQ

Is Have I Been Pwned free?

The Pwned Passwords range API is free and needs no key. Checking whether an email address is in a breach requires a paid API key, priced by rate-limit tier.

How does k-anonymity protect the password?

You hash the password with SHA-1 and send only the first 5 hex characters of the hash. The API returns every breached suffix under that prefix (hundreds of hashes); you match the rest locally, so the service never learns which one you asked about.

Why do I get a 403?

You did not send a User-Agent header. HIBP rejects requests without one to discourage anonymous abuse.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

JSON FormatterJWT DecoderBase64

Related Developer Tools APIs

← Back

More Developer Tools APIs · All 196 APIs