Web API#

The Brax Web Viewer provides HTTP and WebSocket endpoints for real-time visualization and control.

Overview#

The web API is built with FastAPI and provides two main types of endpoints:

  • HTTP endpoints for server control and status

  • WebSocket endpoints for real-time frame streaming and control communication

Documentation Sections#

Quick Reference#

HTTP Endpoints#

  • GET / - Main viewer interface

  • GET /api/rendering_status - Get rendering status

  • POST /api/rendering_status - Set rendering status

WebSocket Endpoints#

  • ws://<host>:<port>/ws/frame - Frame streaming

  • ws://<host>:<port>/ws/control - Control communication

Basic Usage#

Start the server:

python examples/brax/cartpole/viewer.py

Access the viewer: Open http://127.0.0.1:8000 in your browser

Check status:

curl http://127.0.0.1:8000/api/rendering_status

Toggle rendering:

curl -X POST http://127.0.0.1:8000/api/rendering_status \
  -H "Content-Type: application/json" \
  -d '{"rendering_enabled": false}'