One POST from whatever you already have.
Runs in any server. Every name is checked with context: "username" and the teen policy; change the policy to suit the audience. Replace the key.
curl https://api.unprofane.com/v1/check \
-H "Authorization: Bearer up_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"sh1tH3ad_69","context":"username","policy":"teen"}'const res = await fetch('https://api.unprofane.com/v1/check', {
method: 'POST',
headers: { Authorization: 'Bearer up_live_YOUR_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({ text: 'sh1tH3ad_69', context: 'username', policy: 'teen' }),
});
const result = await res.json();
if (!result.allowed) console.log(result.action, result.evasion, result.censored);import { Unprofane } from '@unprofane/sdk';
const unprofane = new Unprofane(process.env.UNPROFANE_API_KEY!);
/** Returns the reason a username cannot be shown, or null when it can. */
export async function usernameProblem(username: string): Promise<string | null> {
const r = await unprofane.check({ text: username, context: 'username', policy: 'teen' });
if (r.allowed) return null;
return r.matches[0]?.category === 'reserved'
? 'That name is reserved.'
: 'Pick a different username.';
}import httpx
r = httpx.post(
"https://api.unprofane.com/v1/check",
headers={"Authorization": "Bearer up_live_YOUR_KEY"},
json={"text": "sh1tH3ad_69", "context": "username", "policy": "teen"},
timeout=5.0,
)
result = r.json()
if not result["allowed"]:
print(result["action"], result["evasion"], result["censored"])req, _ := http.NewRequest("POST", "https://api.unprofane.com/v1/check",
strings.NewReader(`{"text":"sh1tH3ad_69","context":"username","policy":"teen"}`))
req.Header.Set("Authorization", "Bearer up_live_YOUR_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)$res = file_get_contents('https://api.unprofane.com/v1/check', false, stream_context_create(['http' => [
'method' => 'POST',
'header' => "Authorization: Bearer up_live_YOUR_KEY\r\nContent-Type: application/json\r\n",
'content' => json_encode(['text' => 'sh1tH3ad_69', 'context' => 'username', 'policy' => 'teen']),
]]));
$result = json_decode($res, true);require 'net/http'; require 'json'
uri = URI('https://api.unprofane.com/v1/check')
res = Net::HTTP.post(uri, { text: 'sh1tH3ad_69', context: 'username', policy: 'teen' }.to_json,
'Authorization' => 'Bearer up_live_YOUR_KEY', 'Content-Type' => 'application/json')
result = JSON.parse(res.body)using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "up_live_YOUR_KEY");
var res = await http.PostAsJsonAsync("https://api.unprofane.com/v1/check",
new { text = "sh1tH3ad_69", context = "username", policy = "teen" });
var result = await res.Content.ReadFromJsonAsync<JsonElement>();
bool allowed = result.GetProperty("allowed").GetBoolean();var http := HTTPRequest.new()
add_child(http)
http.request_completed.connect(func(_r, _code, _h, body):
var result = JSON.parse_string(body.get_string_from_utf8())
print(result["allowed"], result["action"]))
http.request("https://api.unprofane.com/v1/check", PackedStringArray([
"Authorization: Bearer up_live_YOUR_KEY", "Content-Type: application/json"]),
HTTPClient.METHOD_POST, JSON.stringify({"text": "sh1tH3ad_69", "context": "username", "policy": "teen"}))Keep the secret key on the server. The response’s `allowed` is the decision; `matches[0].category` tells a reserved name from a profane one.
What the response holds, and how to read a reserved name apart from a profane one, is in the API reference. The other recipes are on the username page.