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#
HTTP Endpoints: Detailed HTTP API documentation with examples
WebSocket Endpoints: Real-time communication protocols
Error Handling: Error handling patterns and troubleshooting
Quick Reference#
HTTP Endpoints#
GET /
- Main viewer interfaceGET /api/rendering_status
- Get rendering statusPOST /api/rendering_status
- Set rendering status
WebSocket Endpoints#
ws://<host>:<port>/ws/frame
- Frame streamingws://<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}'