FastPII Docs
Getting Started

Quick Start

Five-minute introduction to detection, validation, redaction, and CLI usage with PrivacyGuard.

Quick Start

This page uses the verified FastPII API from PrivacyGuard.

1. Create a guard and detect PII

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["cz"])

text = "Email: jan.novak@example.cz, RČ: 8001011238"
result = guard.detect(text)

for finding in result.findings:
    print({
        "type": finding.type,
        "value": finding.value,
        "start": finding.start,
        "end": finding.end,
        "confidence": finding.confidence,
        "region": finding.region,
        "metadata": finding.metadata,
    })

Example output:

{
    "type": "email",
    "value": "jan.novak@example.cz",
    "start": 7,
    "end": 27,
    "confidence": 0.95,
    "region": "cz",
    "metadata": {
        "local_part": "jan.novak",
        "domain": "example.cz",
        "is_czech_domain": True,
    },
}
{
    "type": "rodne_cislo",
    "value": "8001011238",
    "start": 33,
    "end": 43,
    "confidence": 0.95,
    "region": "cz",
    "metadata": {
        "checksum_valid": True,
        "birth_date": "1980-01-01",
        "gender": "male",
        "article_9": True,
    },
}

detect() returns a DetectionResult object with:

  • text
  • findings
  • detector_names
  • processing_time_ms

2. Validate a single identifier

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["cz"])
validation = guard.validate("8001011238", "rodne_cislo")

print(validation.is_valid)
print(validation.metadata)

Expected result:

True
{
    "checksum_valid": True,
    "birth_date": "1980-01-01",
    "gender": "male",
    "article_9": True,
}

3. Redact detected values

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["cz"])

text = "Email: jan.novak@example.cz, RČ: 8001011238"
print(guard.redact(text))

Output:

Email: [EMAIL], RČ: [RODNE_CISLO]

4. CLI usage

fastpii detect "Email: jan.novak@example.cz, RČ: 8001011238"

The CLI also supports JSON output:

fastpii detect "Email: jan.novak@example.cz, RČ: 8001011238" --format json

5. Minimal working example

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["cz"])

text = "Kontakt: jan.novak@example.cz, RČ: 8001011238"

detection = guard.detect(text)
validation = guard.validate("8001011238", "rodne_cislo")
redacted = guard.redact(text)

print(len(detection.findings))
print(validation.is_valid)
print(redacted)

On this page