Pastes
Find public pastes that reference an email address. Pastes are text dumps posted to sites like Pastebin. This is an authenticated surface.
Inject in DI
IPwnedPastesClientRetrieves paste records for a given account.
Inject IPwnedPastesClient. Requires an API key on HibpOptions.ApiKey.
using HaveIBeenPwned.Client;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPwnedServices(options =>
{
options.ApiKey = builder.Configuration["Hibp:ApiKey"];
options.UserAgent = "MyApp/1.0";
});
var app = builder.Build();GetPastesAsyncAPI key
Returns every paste that includes the given email address, most recent first. Returns an empty array when none are found.
GEThaveibeenpwned.com/api/v3/pasteaccount/{account}Request detailsHide details
GET /api/v3/pasteaccount/{account} HTTP/1.1Host: haveibeenpwned.comAccept: application/jsonhibp-api-key: ••••••••••••AuthenticationAPI key
The SDK reads the configured key and adds the hibp-api-key header for this request.
Response bodyJSON
Official HIBP reference The SDK deserializes the response into the documented .NET return type.
Task<Pastes[]> GetPastesAsync(
string account,
CancellationToken ct = default)Parameters
| Name | Type | Description |
|---|---|---|
accountrequired | string | Email address to search. Trimmed and URL encoded for you. |
ct | CancellationToken | Signals cancellation. |
Returns
Task<Pastes[]> | Paste records, or an empty array when the account appears in none (HTTP 404). |
| Streams | Also available as GetPastesAsAsyncEnumerable for IAsyncEnumerable consumption. |
Pastes[] pastes = await pastesClient.GetPastesAsync("account@example.com");
foreach (var paste in pastes)
{
Console.WriteLine($"{paste.Source}/{paste.Id}: {paste.EmailCount} emails.");
}Running the snippet above prints:
Pastebin/8Q0BvKD8: 139 emails.
AdHocUrl/example: 42 emails.Exceptions
| Type | Thrown when |
|---|---|
ArgumentNullException | account is null, empty, or whitespace. |
PwnedApiException | Any non-success status other than 404. |
Status codes
| Code | Meaning |
|---|---|
| 200 | Pastes found. |
| 401 | Missing or invalid API key. |
| 404 | No pastes for the account. Returned as an empty array. |
| 429 | Rate limit exceeded. The Retry-After header is surfaced on PwnedApiException.RetryAfter. |
| 503 | Service temporarily unavailable. Retried by the resilience pipeline when configured. |
Privacy note
Never log or export plaintext passwords. K-anonymity range results that do not match the requested value must not be retained.