Anonymizes the request text and de-anonymizes the response text.

1. Example Anonymization request:

import requests
import json
import os

url = "https://api.enkryptai.com/guardrails/pii"

payload = json.dumps({
    "text": "John Everyman, born on January 1, 1970, at 123 Birth Lane, Smalltown, USA, embarked on a journey filled with diverse experiences and milestones. His Social Security number, 456-45-6789, was issued in his home state, marking the beginning of his financial footprint. Here is my email: example@example.com",
    "mode": "request",
    "key": None,
    "entities": [
        "US_SSN"
    ]
})
headers = {
  'Content-Type': 'application/json',
  'apikey': os.getenv('ENKRYPTAI_API_KEY')
}

response = requests.request("POST", url, headers=headers, data=payload)

formatted_response = json.dumps(json.loads(response.text), indent=4)
print(formatted_response)

Anonymization response:

{
	"text": "<PERSON_0>, born on <DATE_TIME_0>, at 123 Birth Lane, <LOCATION_1>, <LOCATION_0>, embarked on a journey filled with diverse experiences and milestones. His Social Security number, <US_SSN_0>, was issued in his home state, marking the beginning of his financial footprint. Here is my email: <EMAIL_ADDRESS_0>",
	"key": "e0d23d58abe14b2babb3be5aeab8250e"
}

2. Example de-anonymization request:

import requests

url = "https://api.enkryptai.com/guardrails/pii"

payload = {
    "text": "<PERSON_0>, born on <DATE_TIME_0>, at 123 Birth Lane, <LOCATION_1>, <LOCATION_0>, embarked on a journey filled with diverse experiences and milestones. His Social Security number, <US_SSN_0>, was issued in his home state, marking the beginning of his financial footprint. Here is my email: <EMAIL_ADDRESS_0>",
    "mode": "response",
    "key": "e0d23d58abe14b2babb3be5aeab8250e"
}
headers = {
    "Content-Type": "application/json",
    'apikey': os.getenv('ENKRYPTAI_API_KEY')

}

response = requests.request("POST", url, json=payload, headers=headers)

formatted_response = json.dumps(json.loads(response.text), indent=4)
print(formatted_response)

De-anonymization response:

{
	"text": "John Everyman, born on January 1, 1970, at 123 Birth Lane, Smalltown, USA, embarked on a journey filled with diverse experiences and milestones. His Social Security number, 456-45-6789, was issued in his home state, marking the beginning of his financial footprint. Here is my email: example@example.com",
	"key": "e0d23d58abe14b2babb3be5aeab8250e"
}