PII
Introduction to PII
Personally Identifiable Information (PII) refers to any data that could potentially identify a specific individual. This includes, but is not limited to, names, addresses, phone numbers, and social security numbers. Managing PII is crucial for maintaining privacy and complying with regulations such as GDPR and CCPA. The FastAPI PII domain provides endpoints to detect and manage PII within your applications, ensuring that sensitive information is handled appropriately.
Key Concepts
Detecting PII
The POST /v1/pii/detect endpoint allows you to analyze text data and identify PII. This can be useful for applications that need to process user-generated content or handle large datasets containing sensitive information. The endpoint returns a structured response indicating the types of PII detected and their locations within the input text.
PII Types
The GET /v1/pii/types endpoint provides a list of all PII types that the API can detect. This is useful for understanding the scope of detection capabilities and ensuring that your application can handle all relevant PII types.
Common Workflows
Workflow: Detecting PII in Text
-
Retrieve PII Types: Before detecting PII, you may want to know which types of PII the API can detect. Use the
GET /v1/pii/typesendpoint to retrieve this information. -
Detect PII: Use the
POST /v1/pii/detectendpoint to analyze your text data. Submit the text in the request body, and the API will return a list of detected PII types and their locations.
Practical Example
Detecting PII
To detect PII in a given text, you can use the following curl command:
curl -X POST "https://api.example.com/v1/pii/detect" \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key" \
-d '{"text": "John Doe lives at 123 Main St, Anytown, USA."}'This request will return a JSON response indicating the detected PII, such as:
{
"detected_pii": [
{"type": "Name", "value": "John Doe", "start": 0, "end": 8},
{"type": "Address", "value": "123 Main St, Anytown, USA", "start": 18, "end": 46}
]
}Retrieving PII Types
To get a list of detectable PII types, use the following curl command:
curl -X GET "https://api.example.com/v1/pii/types" \
-H "X-API-Key: your_api_key"This will return a JSON array of PII types, such as:
["Name", "Address", "Phone Number", "Email"]Important Considerations
Authentication
While the X-API-Key header is optional, it is recommended to use it to authenticate your requests. This ensures that your requests are authorized and helps in tracking usage.
Error Handling
Ensure your application handles potential errors gracefully. Common errors include invalid input data and unauthorized access. Check the response status codes and messages to understand and resolve issues.
Data Privacy
When sending data to the API, ensure that you comply with relevant data protection regulations. Avoid sending unnecessary sensitive information and ensure that data is encrypted in transit.
By integrating the PII detection capabilities of the FastAPI PII domain, you can enhance your application's ability to manage sensitive information effectively, ensuring compliance and protecting user privacy.