xposedornot-go
Official Go SDK for the XposedOrNot API
Check if your email or password has been exposed in data breaches
Note: This SDK uses the free public API from XposedOrNot.com - a free service to check if your email has been compromised in data breaches. A Plus API with enhanced features is available with an API key. Visit the XposedOrNot website to learn more.
Table of Contents
Features
- Simple API - Idiomatic Go client with functional options pattern
- Context Support - All methods accept
context.Context for cancellation and timeouts
- Free and Plus APIs - Use the free API or unlock detailed results with an API key
- Detailed Analytics - Get breach details, risk scores, metrics, and paste exposures
- Error Handling - Typed error values compatible with
errors.As
- Password Privacy - Passwords are hashed locally; only a short prefix is sent (k-anonymity)
- Rate Limiting - Built-in client-side rate limiting with automatic retry on 429 responses
- Secure - HTTPS enforced on all base URLs by default
Installation
go get github.com/XposedOrNot/XposedOrNot-Go
Requirements
Quick Start
package main
import (
"context"
"fmt"
"log"
xon "github.com/XposedOrNot/XposedOrNot-Go"
)
func main() {
client, err := xon.NewClient()
if err != nil {
log.Fatal(err)
}
// Check if an email has been breached
free, _, err := client.CheckEmail(context.Background(), "test@example.com")
if err != nil {
log.Fatal(err)
}
if len(free.Breaches) > 0 {
fmt.Printf("Email found in %d breaches:\n", len(free.Breaches))
for _, b := range free.Breaches {
fmt.Printf(" - %s\n", b)
}
} else {
fmt.Println("Good news! Email not found in any known breaches.")
}
}
API Reference
Constructor
client, err := xon.NewClient(opts ...xon.ClientOption)
Create a new client with functional options. See Configuration Options for all available options.
Methods
CheckEmail(ctx, email, opts...)
Check if an email address has been exposed in any data breaches. Returns the free API response or the Plus API response depending on whether an API key is configured.
// Free API (no API key)
free, _, err := client.CheckEmail(ctx, "user@example.com")
if err != nil {
log.Fatal(err)
}
fmt.Println("Breaches:", free.BreachNames())
fmt.Println("Status:", free.Status)
free, _, err = client.CheckEmail(ctx, "user@example.com", xon.WithIncludeDetails())
// Plus API (with API key)
client, _ := xon.NewClient(xon.WithAPIKey("your-api-key"))
_, plus, err := client.CheckEmail(ctx, "user@example.com")
if err != nil {
log.Fatal(err)
}
for _, b := range plus.Breaches {
fmt.Printf("Breach: %s, Date: %s, Records: %d\n",
b.BreachID, b.BreachedDate, b.XposedRecords)
}
Signature:
func (c *Client) CheckEmail(ctx context.Context, email string, opts ...RequestOption) (*CheckEmailFreeResponse, *CheckEmailPlusResponse, error)
| Return Value |
Type |
Description |
free |
*CheckEmailFreeResponse |
Populated when no API key is set (Plus response is nil) |
plus |
*CheckEmailPlusResponse |
Populated when an API key is set (Free response is nil) |
err |
error |
Non-nil on validation failure, network error, or API error |
WithIncludeDetails() requests detailed breach information from the free API. It is ignored when an API key is set, because the Plus API is always queried with detailed results. CheckEmailFreeResponse exposes Email, Status, and a BreachNames() helper that flattens the breach list.
GetBreaches(ctx, domain, opts...)
Retrieve a list of all known data breaches. Pass a non-empty domain string to filter results by domain, or use WithBreachID to fetch a specific breach.
// Get all breaches
all, err := client.GetBreaches(ctx, "")
if err != nil {
log.Fatal(err)
}
fmt.Println("Total known breaches:", len(all.ExposedBreaches))
// Filter by domain
adobe, err := client.GetBreaches(ctx, "adobe.com")
if err != nil {
log.Fatal(err)
}
fmt.Println("Adobe breaches:", len(adobe.ExposedBreaches))
one, err := client.GetBreaches(ctx, "", xon.WithBreachID("Adobe"))
if err != nil {
log.Fatal(err)
}
fmt.Println("Breach:", one.ExposedBreaches[0].BreachID)
Signature:
func (c *Client) GetBreaches(ctx context.Context, domain string, opts ...RequestOption) (*GetBreachesResponse, error)
| Parameter |
Type |
Description |
ctx |
context.Context |
Context for cancellation and timeouts |
domain |
string |
Filter by domain (pass "" for all breaches) |
opts |
...RequestOption |
Optional request options such as WithBreachID(id) |
Returns: *GetBreachesResponse containing a slice of ExposedBreach with fields including BreachID, BreachedDate, Domain, Industry, ExposedData, ExposedRecords, and Verified.
BreachAnalytics(ctx, email, opts...)
Get detailed breach analytics for an email address, including breach details, summary statistics, metrics breakdowns, and paste exposures. Use WithToken to access sensitive breach data.
analytics, err := client.BreachAnalytics(ctx, "user@example.com")
if err != nil {
log.Fatal(err)
}
fmt.Println("Breach details:", len(analytics.ExposedBreaches.BreachesDetails))
fmt.Println("Breach names:", analytics.BreachesSummary.BreachNames())
fmt.Println("Total breaches:", analytics.BreachesSummary.TotalBreaches)
fmt.Println("Most recent:", analytics.BreachesSummary.MostRecentBreach)
analytics, err = client.BreachAnalytics(ctx, "user@example.com", xon.WithToken("your-token"))
Signature:
func (c *Client) BreachAnalytics(ctx context.Context, email string, opts ...RequestOption) (*BreachAnalyticsResponse, error)
| Parameter |
Type |
Description |
ctx |
context.Context |
Context for cancellation and timeouts |
email |
string |
Email address to analyze |
opts |
...RequestOption |
Optional request options such as WithToken(token) |
Returns: *BreachAnalyticsResponse with the following fields:
| Field |
Type |
Description |
ExposedBreaches |
ExposedBreachesWrapper |
Detailed list of each breach |
BreachesSummary |
BreachesSummary |
Summary stats (total breaches, date range, risk) |
BreachMetrics |
BreachMetrics |
Breakdowns by industry, password strength, year, and data type |
PastesSummary |
PasteSummary |
Paste exposure summary |
ExposedPastes |
[]interface{} |
Raw paste exposure entries |
GetDomainBreaches(ctx)
Get breach information for the domains verified against your API key. Requires an API key with domains verified at the free CXO dashboard.
client, _ := xon.NewClient(xon.WithAPIKey("your-api-key"))
report, err := client.GetDomainBreaches(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println("Domain summary:", report.Metrics.DomainSummary)
fmt.Println("Yearly metrics:", report.Metrics.YearlyMetrics)
fmt.Println("Top 10 breaches:", report.Metrics.Top10Breaches)
for _, record := range report.Metrics.BreachesDetails {
fmt.Printf(" %s (%s): %s\n", record.Email, record.Domain, record.Breach)
}
Signature: