An HTTPRequest for the name field.
Runs in GDScript. Every name is checked with context: "username" and the teen policy; change the policy to suit the audience. Replace the key.
# Username field: a publishable key (up_pk_…) with your game's origin allowed.
func check_username(username: String) -> void:
var http := HTTPRequest.new()
add_child(http)
http.request_completed.connect(_on_checked)
http.request("https://api.unprofane.com/v1/check",
PackedStringArray(["Authorization: Bearer up_pk_YOUR_PUBLISHABLE_KEY", "Content-Type: application/json"]),
HTTPClient.METHOD_POST,
JSON.stringify({"text": username, "context": "username", "policy": "teen"}))
func _on_checked(_result, _code, _headers, body) -> void:
var r = JSON.parse_string(body.get_string_from_utf8())
if not r["allowed"]:
show_error("Pick a different username.")The same rule as Unity: the publishable key gives the live hint, your server makes the decision with a secret key.
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.