City (PII)
METHOD: POST
ENDPOINT: https://api.playground.protegrity.com/v1/city
DESCRIPTION:
Protect or unprotect a town or city. The received token is not length-preserving.
ATTRIBUTES:
data
(required) Input data to transform.
operation
(required) Specify if to protect or unprotect data. Accepts: [ protect | unprotect ]
.
user
(optional) Choose a user to impersonate from the list of pre-configured roles.
OPTIONS:
dictionary
(optional) Specify the Unicode domain of the input and output values. Option en
covers all characters within the Basic Latin block of the Unicode standard (range U+0000..U+007F). Options de
and fr
extend that coverage to include German and French characters, respectively. Accepts: [ en | de | fr ]
. Defaults to en
.
eiv
(optional) Provide your custom initialization vector to introduce additional variance in the output. The IV may be a number, letter, special character, or a combination of those. Learn more about the IVs in the Key Concepts section. Note that to unprotect the data back to its original value, the eiv
has to be provided in the payload.
SAMPLE REQUEST
curl --location 'https://api.playground.protegrity.com/v1/city' \
--header 'x-api-key: <API_Key>' \
--header 'Content-Type: application/json' \
--header 'Authorization: <JWT_TOKEN>' \
--data '{
"operation": "protect",
"data": ["Berlin", "München"],
"options": {
"dictionary": "de"
}
}'
import requests
import json
JWT_Token = "<JWT_TOKEN>"
API_Key = "<API_Key>"
url = 'https://api.playground.protegrity.com/v1/city'
headers = { 'x-api-key': API_Key, 'Content-Type': 'application/json', 'Authorization': JWT_Token }
data = {
"operation": "protect",
"data": ["Berlin", "München"],
"options": {
"dictionary": "de"
}
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class APIRequest { public static void main(String[] args) {
try {
String JWT_Token = "<JWT_TOKEN>"
String API_Key = "<API_Key>"
URI uri = new URI("https://api.playground.protegrity.com/v1/city");
URL url = uri.toURL();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("x-api-key", API_Key);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", JWT_Token); conn.setDoOutput(true);
String jsonInputString = "{ \"operation\": \"protect\", \"data\": [\"Berlin\", \"München\"], \"options\": { \"dictionary\": \"de\" } }";
try (OutputStream os = conn.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
fetch('https://api.playground.protegrity.com/v1/city',
{ method: 'POST',
headers: { 'x-api-key': '<API_Key>', 'Content-Type': 'application/json', 'Authorization': '<JWT_TOKEN>' },
body: JSON.stringify({
"operation": "protect",
"data": ["Berlin", "München"],
"options": { "dictionary": "de" }
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"io"
"fmt"
"strings"
"net/http"
)
func main() {
JWT_Token := "<JWT_TOKEN>"
API_Key := "<API_Key>"
url := "https://api.playground.protegrity.com/v1/city"
data := strings.NewReader(`{
"operation": "protect",
"data": ["Berlin", "München"],
"options": {"dictionary": "de"}
}`)
req, err := http.NewRequest("POST", url, data)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("x-api-key", API_Key)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", JWT_Token)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
SAMPLE RESPONSE
[
"hjsöIO",
"YAßiaoP"
]
Last modified March 4, 2025