Creative Golf OpenAPI
Examples 1.0.0 · Protocol 2

JavaScript / Node.js OpenAPI console example

Requires Node.js 22 or newer (verified with 24.18.0). Uses only built-in modules; no npm packages or compilation are needed. Run it in Node.js, not directly in a web browser.

Run

From this folder:

Game on the same PC:

node src/openapi_example.js

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

node src/openapi_example.js 192.168.1.100 4356

The example is source-only. Use the GUI TestApp in the final package if you want 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.

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.js with new live measurements from your hardware. Device status is independent of game readiness. See the API reference for fields, units and results.