JavaScript and Python examples
These clients connect, authenticate when required, read GET_SETTINGS, print the response, and close. They send no control inputs by default. Follow Get started to enable the server.
| Client | Download | Requirements |
|---|---|---|
| JavaScript | client.mjs | Node.js 22.4+; no npm dependencies |
| Python | client.py and requirements.txt | Python 3.11+ |
Set your authentication key
Section titled “Set your authentication key”Enter the key from PlayAbility at a hidden prompt, then run the client in the same terminal. This keeps the key out of your shell history.
macOS (zsh):
read -rs 'PLAYABILITY_WS_KEY?PlayAbility key: 'export PLAYABILITY_WS_KEYBash:
read -rs -p 'PlayAbility key: ' PLAYABILITY_WS_KEYexport PLAYABILITY_WS_KEYWindows PowerShell:
$secureKey = Read-Host 'PlayAbility key' -AsSecureString$env:PLAYABILITY_WS_KEY = [System.Net.NetworkCredential]::new('', $secureKey).PasswordRemove-Variable secureKeyRun JavaScript
Section titled “Run JavaScript”Save the file and run from its folder:
node client.mjsRun Python
Section titled “Run Python”Save both files in the same folder, then:
python3 -m venv .venvsource .venv/bin/activatepython -m pip install -r requirements.txtpython client.pyOn Windows, replace the first two lines with py -3.11 -m venv .venv and .venv\Scripts\Activate.ps1. You can select another installed Python 3.11+ version.
Optionally test the A button
Section titled “Optionally test the A button”Enable Allow WebSocket Inputs, Main Output, and gamepad output in PlayAbility. Choose a target application where pressing A is appropriate, then run either:
node client.mjs --press-apython client.py --press-aThe clients check those settings, send a press and an explicit release, and add a 500 ms fallback release. Inputs have no execution acknowledgment: verify the result in PlayAbility or the target application. If the connection drops, check that the button was released.
After testing, close the terminal or clear the key with unset PLAYABILITY_WS_KEY (macOS/Linux) or Remove-Item Env:PLAYABILITY_WS_KEY (PowerShell).