Unprofane

Godot username check for the name screen

An HTTPRequest for the name field, with the real check on your server.

Your game’s name screenExample

Choose your player name

Everyone in the game will see it.

sh1tH3ad_69

Pick a different username.

Choose your player name

Everyone in the game will see it.

admin

That name is reserved.

Choose your player name

Everyone in the game will see it.

river_otter

Name saved

Unprofane
blockleetspeak
Your server
"Pick a different username."
Unprofane
blockreserved
Your server
"That name is reserved."
Unprofane
allow
Your server
null
Try a name

Live in four steps

Build with a test key, 100 checks a month; switch to a live key when you ship.

  1. Before you start

    • Godot 4, and your own server, which checks the final name.

      Any language works; the code below is TypeScript.

    • For the live hint in a Web export: a publishable key (up_pk_…) and your game page’s origin on the project in the dashboard.

      Publishable keys need a plan.

  2. Store the key

    • The secret key lives on your server only, as UNPROFANE_API_KEY.

    • The publishable key goes in the export, where anyone can read it.

      It can only call /v1/check, and only from the origins you list.

  3. Where the file goes

    • A script on your name screen’s node, such as name_screen.gd.

      Connect username_checked to whatever shows the hint, and call check_username a moment after the player stops typing.

      The server code goes in the route your game calls to save a name.

    # Godot 4, Web export only: the live hint as the player types, with a publishable key
    # (up_pk_…) and your game page's origin allowed on the project. A desktop or mobile build
    # sends no origin, so the key is refused there: have it ask your server instead.
    # Either way your server checks the final name with a secret key; a key in a build is public.
    signal username_checked(allowed: bool)
    
    func check_username(username: String) -> void:
    	var http := HTTPRequest.new()
    	add_child(http)
    	http.request_completed.connect(_on_checked.bind(http))
    	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: int, code: int, _headers: PackedStringArray, body: PackedByteArray, http: HTTPRequest) -> void:
    	http.queue_free()
    	# No answer is not a no: the hint stays quiet and your server decides.
    	if result != HTTPRequest.RESULT_SUCCESS or code != 200:
    		username_checked.emit(true)
    		return
    	var r = JSON.parse_string(body.get_string_from_utf8())
    	username_checked.emit(r["allowed"])
    1. Line 12A publishable key: it can only call /v1/check, and only from the origins you list.
    2. Line 17Each request frees its node when it answers.
    3. Line 20No answer is not a no: the hint stays quiet and your server decides.

    Replace up_pk_YOUR_PUBLISHABLE_KEY with your key; nothing else changes. Every name goes with context: "username" and the teen policy.

    The decision, on your server. The second tab, the raw HTTP recipe, checks the name with a secret key before it is saved.

  4. Check that it works

    • On your server with a test key, check sh1tH3ad_69 (refused), admin (reserved) and river_otter (allowed).

    • In a Web export, type the same names and the hint follows.

      In the editor or a desktop export the hint’s request answers 403, because those send no origin.

    What your server’s check is run with

    1. sh1tH3ad_69"Pick a different username."
    2. admin"That name is reserved."
    3. river_otternull
    4. Unprofane unreachablethrows

It reads the name, not a list

Six usernames a word list gets wrong, and what this check answered.

  1. sh1tH3ad_69

    Digits for letters

    Misses it

    blockreads shitheadleetspeak
  2. ilovesh1t

    Words run together

    Misses it

    blockreads shitleetspeakconcatenation
  3. tihs_xX

    Written backwards

    Misses it

    blockreads shitreversed
  4. admin

    Not rude: a claim to be staff

    Passes it

    blockreserved
  5. Dickinson

    A poet’s surname

    Blocks it

    allow
  6. therapist_jo

    A job

    Blocks it

    allow
Out of 6

4 let through2 innocent blocked

4 turned away2 innocent let through

76.5%

Unprofane

Balanced mode, as the recipes run it

32.5%

Perspective API

Set to flag as much clean text as Unprofane

Toxic usernames caught. Held-back judged test set, run of .How it was measured

How it behaves in production

When it runs, what it does with each answer, and what usually goes wrong.

When the check runs
  1. Typed
  2. Hint while typing
  3. Sent to your server
  4. Unprofane checks
  5. Saved

The hint is a courtesy, while the player types. The decision is your server’s, when the game sends the name to be saved: refuse the save there, whatever the client said.

Allow, review and block
allow
Goes through
review
Turned away, like a block
block
Turned away

allowed is true only when action is allow. The recipes turn away review as well as block: a username has no moderator queue, and asking for another name costs the person a few seconds. To accept a name held for review and look at it later, test action !== "block" instead and keep the user id where a person will read it. A name that claims to be the platform or its staff, such as admin, comes back with matches[0].category set to reserved, and the code says so in its own words.

Every field of the answer is in the API reference.

When Unprofane does not answer

When the hint’s request fails, the script emits username_checked(true): the hint stays quiet and the player carries on. Your server then decides, and when Unprofane does not answer it, usernameProblem throws: refuse the save and ask the player to try again.

How this recipe is held to the API

The GDScript is not run: there is no Godot in our CI. Its request is held to the API’s fields on every change. The server half is the raw HTTP recipe’s TypeScript, which is run on every change.

403: this origin is not allowed

The request came from a desktop, mobile or editor build, or from an origin not on the project’s list. Native exports ask your server instead.

401: no valid API key

The key is not where the code reads it, or it was revoked. Set it again and deploy again.

402: a plan is required

A live or publishable key needs a plan. Build with a test key (up_test_…), which needs none.

429: too many requests

A test key’s free checks are capped across the account, a month’s with no plan and a day’s on one, and every plan has a per-minute limit. The answer’s type says which.

Every error, and what to send instead, is on the errors page.

The same check, elsewhere

Each recipe is a complete file, run the same way.

Run this recipe with your API key

Paste the file, set the key, and send it sh1tH3ad_69, admin and river_otter.

Get your API key