Request/Response Details
Request Structure
Complete Request Example
{
"id": "req-001",
"v": 1,
"method": "browser.fill",
"params": {
"selector": "input#email",
"value": "user@example.com",
"session": "login-flow"
}
}
Method Naming
Methods follow the pattern: <service>.<action>
browser.open- Browser service, open actiongmail.send- Gmail service, send actionsession.new- Session management
Some daemons accept shorthand: - open → browser.open - click → browser.click
Parameter Types
Parameters are method-specific. Common patterns:
// URL parameter
{"url": "https://example.com"}
// Selector parameter
{"selector": "button.submit"}
// Session parameter (optional)
{"session": "my-session"}
// Multiple parameters
{
"selector": "input",
"value": "hello",
"timeout": 5000
}
Response Structure
Success Response
{
"id": "req-001",
"ok": true,
"result": {
"filled": true,
"selector": "input#email"
},
"meta": {
"server_ms": 12.3,
"protocol_v": 1
}
}
Error Response
{
"id": "req-001",
"ok": false,
"error": "Timeout waiting for element: input#email",
"meta": {
"server_ms": 5002.1,
"protocol_v": 1
}
}
Error Codes
Errors are returned as human-readable strings. Common patterns:
| Error | Meaning |
|---|---|
Element not found: <selector> | Selector didn't match any element |
Timeout waiting for: <selector> | Element didn't appear in time |
Navigation failed: <url> | Page failed to load |
Unknown method: <method> | Method doesn't exist |
Invalid params: <detail> | Parameter validation failed |
Result Types
Results vary by method:
Void Results
Some methods return minimal confirmation:
Data Results
Methods that fetch data return structured results:
{
"ok": true,
"result": {
"title": "Page Title",
"url": "https://example.com/page",
"aria_tree": "document...",
"timestamp": "2025-01-14T12:00:00Z"
}
}
Binary Results
Binary data (screenshots) are base64-encoded or saved to files:
Timing Information
The meta.server_ms field shows server processing time:
This excludes: - Client connection time - Network latency (minimal for UNIX sockets) - Client JSON parsing
Best Practices
Generate Unique IDs
Use UUIDs or incrementing counters:
Handle Errors
Always check ok before accessing result:
response = send_request(...)
if response["ok"]:
process(response["result"])
else:
handle_error(response["error"])
Set Reasonable Timeouts
Client-side timeouts should exceed expected operation time: