WebSocket API Reference
Reference for the /ws WebSocket endpoint of the Computer Server.
WebSocket API Reference
The Computer Server exposes a WebSocket endpoint for real-time command execution and streaming results.
ws://localhost:8000/ws
wss://your-container.containers.cloud.trycua.com:8443/ws
(cloud)
Authentication (Cloud Only)
For cloud containers, you must authenticate immediately after connecting:
{
"command": "authenticate",
"params": {
"container_name": "your-container",
"api_key": "your-api-key"
}
}
If authentication fails, the connection is closed.
Command Format
Send JSON messages:
{
"command": "<command_name>",
"params": { ... }
}
Example (Python)
import websockets
import asyncio
import json
async def main():
uri = "ws://localhost:8000/ws"
async with websockets.connect(uri) as ws:
await ws.send(json.dumps({"command": "version", "params": {}}))
response = await ws.recv()
print(response)
asyncio.run(main())
Example (Cloud)
import websockets
import asyncio
import json
async def main():
uri = "wss://your-container.containers.cloud.trycua.com:8443/ws"
async with websockets.connect(uri) as ws:
await ws.send(json.dumps({
"command": "authenticate",
"params": {
"container_name": "your-container",
"api_key": "your-api-key"
}
}))
auth_response = await ws.recv()
print(auth_response)
await ws.send(json.dumps({"command": "version", "params": {}}))
response = await ws.recv()
print(response)
asyncio.run(main())
Response Format
Each response is a JSON object:
{
"success": true,
...
}
Supported Commands
See Commands Reference for the full list of commands and parameters.