Reference
API Reference
Complete reference for PrivacyGuard and the exported FastPII data models.
from fastpii import PrivacyGuard, Finding, DetectionResult, ValidationResult
PrivacyGuard(regions: list[str] | None = None)
| Parameter | Type | Description |
|---|
regions | `list[str] | None` |
detect(text: str, detector_names: list[str] | None = None) -> DetectionResult
| Parameter | Type | Description |
|---|
text | str | Input text to scan |
detector_names | `list[str] | None` |
| Returns | Type | Description |
|---|
| return value | DetectionResult | Detection output with findings and timing |
validate(value: str, detector_name: str) -> ValidationResult
| Parameter | Type | Description |
|---|
value | str | Value to validate |
detector_name | str | Detector that should validate the value |
| Returns | Type | Description |
|---|
| return value | ValidationResult | Validation outcome and detector metadata |
anonymize(text: str, replacement: str = "[REDACTED]") -> str
| Parameter | Type | Description |
|---|
text | str | Input text containing PII |
replacement | str | Placeholder used for every detected span |
Returns text where each finding is replaced with a label such as [EMAIL] or [RODNE_CISLO].
Returns text where each finding is replaced by * characters matching the original value length.
Returns text with detected PII removed entirely.
register_detector(detector) -> None
Registers a custom detector instance.
Returns the detector registered under name.
Returns all registered detector instances.
| Field | Type | Description |
|---|
type | str | Detector type, such as email or ico |
value | str | Matched value |
start | int | Start index in the original text |
end | int | End index in the original text |
confidence | float | Confidence score for the match |
region | str | Region code such as cz |
metadata | dict[str, Any] | Optional detector-specific metadata |
| Field | Type | Description |
|---|
text | str | Original text passed to detect() |
findings | list[Finding] | Deduplicated findings |
detector_names | list[str] | Types of findings that survived overlap resolution |
processing_time_ms | int | Detection time in milliseconds |
| Field | Type | Description |
|---|
detector | str | Detector name used for validation |
value | str | Value passed to validate() |
is_valid | bool | Whether validation succeeded |
metadata | dict[str, Any] | Optional detector-specific metadata |
from fastpii import PrivacyGuard
guard = PrivacyGuard(regions=["cz"])
result = guard.detect("Jan Novák, email: jan.novak@email.cz, RČ: 8001011238")
validation = guard.validate("25596641", "ico")