Creative Golf OpenAPI
Examples 1.0.0 · Protocol 2

Python OpenAPI console example

Requires Python 3.10 or newer. Uses only the standard library; no packages to install or compilation step.

Run

From this folder:

Game on the same PC:

python src/openapi_example.py

Optional: game on another PC. Replace 192.168.1.100 with that PC's IP address. 4356 is the default game port.

python src/openapi_example.py --host 192.168.1.100 --port 4356

On Windows, py can replace python if you use the Python launcher. The example is source-only; no Python EXE/runtime is included. Use the GUI TestApp in the final package for a ready-to-run application without development tools.

Try it

Run Creative Golf with OpenAPI selected. Only one client can connect at a time. Defaults are 127.0.0.1:4356; optional arguments select the game PC and port.

Connection failure waits for Enter to retry or Esc to exit. The menu appears after the server's hello:

1 - Send normal shot
2 - Send putt
3 - Set device Ready
4 - Set device Not ready
5 - Show current game state
0 - Disconnect and exit
m - Show this menu

Type a choice and press Enter. Text aliases shot, putt, ready, notready, state, quit, menu also work. Status sends only ballReady, without a reason prompt. With redirected UTF-8 input, a blank line retries; esc, an Escape character or EOF cancels the initial connection attempt. On server disconnect, press Enter to leave the input prompt.

TX / RX show sent / received JSON. Each shot has a new UUID. Not-ready commands are discarded, and another shot needs the previous result and a fresh ready state. No automatic reconnect, queuing or replay. State messages replace the full snapshot; omitted fields clear old values. The game may still reject a shot after advertising readiness.

Replace the two presets in src/openapi_example.py with new live measurements from your hardware. Device status is independent of game readiness. See the API reference for fields, units and results.