Since 12.1.1, X-Plane has a web API built in. It speaks JSON, which is far nicer to work with than packing bytes into UDP packets.
There's one big limit. It only answers programs on the same computer. If your display lives on another PC, stick with UDP or write a small relay.
Check it's there
With the sim running, open http://localhost:8086/api/capabilities in your browser. You should get the supported API versions and your X-Plane version.
Port 8086 is the default. The --web_server_port command line option changes it.
IDs, then values
You can't ask for a dataref by name when you read it. You look up its ID first. IDs hold for as long as the sim runs, and they can change next time, so look them up on every start. The list is empty until a flight has loaded.
Stream values
This needs Node 22 or later, which includes WebSocket. Save it as and run it with .
