Skip to main content
Version: Latest

API Reference

EXPERIMENTAL API

This API is experimental and under active development. While core endpoints are implemented and functional, some advanced features and CLI integration are still in development.

Current Status:

  • โœ… Core endpoints functional (health, state_structure, observation, execute)
  • โœ… Mock mode fully operational for testing
  • โš ๏ธ CLI integration requires Brobot CLI JAR (experimental)
  • โš ๏ธ Some documented parameters not yet implemented
  • โš ๏ธ API may change in future versions

Use for research, prototyping, and development purposes.

Complete reference documentation for all MCP Server API endpoints.

Base URLโ€‹

http://localhost:8000/api/v1

Authenticationโ€‹

Currently, the API does not require authentication. Future versions will support API key authentication.

Content Typesโ€‹

  • Request: application/json
  • Response: application/json
  • Encoding: UTF-8

Response Formatโ€‹

All responses use JSON format with UTF-8 encoding:

Content-Type: application/json
FUTURE FEATURE

Request tracking headers (X-Request-ID, X-Response-Time) are planned for future releases.

Endpointsโ€‹

Health Checkโ€‹

GET /api/v1/healthโ€‹

Check server health and Brobot CLI connectivity.

Response

{
"status": "ok",
"version": "0.1.0",
"brobot_connected": true,
"timestamp": "2024-01-20T10:30:00Z"
}

Status Codes

  • 200 OK: Server is healthy
  • 503 Service Unavailable: Server is unhealthy

Example

curl http://localhost:8000/api/v1/health

Get State Structureโ€‹

GET /api/v1/state_structureโ€‹

Retrieve the complete state structure of the target application.

Response

{
"states": [
{
"name": "main_menu",
"description": "Application main menu",
"images": [
"main_menu_logo.png",
"menu_button.png"
],
"transitions": [
{
"from_state": "main_menu",
"to_state": "login_screen",
"action": "click_login",
"probability": 0.95
}
],
"is_initial": true,
"is_final": false
}
],
"current_state": "main_menu",
"metadata": {
"application": "MyApp",
"version": "1.0.0",
"last_updated": "2024-01-20T10:30:00Z"
}
}

Response Schema

FieldTypeDescription
statesarrayList of all application states
states[].namestringUnique state identifier
states[].descriptionstringHuman-readable description
states[].imagesarrayAssociated image patterns
states[].transitionsarrayPossible state transitions
states[].is_initialbooleanWhether this is a starting state
states[].is_finalbooleanWhether this is an ending state
current_statestringCurrently active state name
metadataobjectAdditional information

Status Codes

  • 200 OK: Success
  • 500 Internal Server Error: CLI error

Example

import requests

response = requests.get("http://localhost:8000/api/v1/state_structure")
states = response.json()["states"]
print(f"Found {len(states)} states")

Get Observationโ€‹

GET /api/v1/observationโ€‹

Get current observation including screenshot and active states.

NOTE

Currently, this endpoint always returns a full observation with screenshot. Query parameters for filtering are planned for future releases.

Response

{
"timestamp": "2024-01-20T10:30:00Z",
"active_states": [
{
"name": "dashboard",
"confidence": 0.95,
"matched_patterns": [
"dashboard_header.png",
"user_menu.png"
]
},
{
"name": "notifications",
"confidence": 0.72,
"matched_patterns": [
"notification_bell.png"
]
}
],
"screenshot": "iVBORw0KGgoAAAANS...",
"screen_width": 1920,
"screen_height": 1080,
"metadata": {
"capture_duration": 0.125,
"analysis_duration": 0.087,
"total_patterns_checked": 42,
"patterns_matched": 3
}
}

Response Schema

FieldTypeDescription
timestampstringISO 8601 timestamp
active_statesarrayCurrently active states
active_states[].namestringState name
active_states[].confidencefloatConfidence score (0.0-1.0)
active_states[].matched_patternsarrayPatterns that matched
screenshotstringBase64 encoded image
screen_widthintegerScreen width in pixels
screen_heightintegerScreen height in pixels
metadataobjectPerformance metrics

Status Codes

  • 200 OK: Success
  • 500 Internal Server Error: Screenshot capture failed

Example

import requests
import base64

# Get observation (always includes screenshot)
response = requests.get("http://localhost:8000/api/v1/observation")
obs = response.json()

# Save screenshot to file
if obs.get("screenshot"):
img_data = base64.b64decode(obs["screenshot"])
with open("screen.png", "wb") as f:
f.write(img_data)

Execute Actionโ€‹

POST /api/v1/executeโ€‹

Execute an automation action on the target application.

Request Body

{
"action_type": "click",
"parameters": {
"image_pattern": "submit_button.png",
"confidence": 0.9,
"timeout": 5.0
},
"target_state": "form_submitted",
"timeout": 10.0
}

Request Schema

FieldTypeRequiredDescription
action_typestringYesType of action to execute
parametersobjectYesAction-specific parameters
target_statestringNoExpected state after action
timeoutfloatNoAction timeout in seconds (default: 10.0)

Response

{
"success": true,
"action_type": "click",
"duration": 0.523,
"result_state": "form_submitted",
"error": null,
"metadata": {
"click_location": {
"x": 640,
"y": 480
},
"pattern_found": true,
"confidence": 0.92,
"search_time": 0.234
}
}

Response Schema

FieldTypeDescription
successbooleanWhether action succeeded
action_typestringType of action executed
durationfloatExecution time in seconds
result_statestringState after execution
errorstringError message if failed
metadataobjectAction-specific details

Status Codes

  • 200 OK: Action completed (check success field)
  • 400 Bad Request: Invalid parameters
  • 422 Unprocessable Entity: Validation error
  • 500 Internal Server Error: Execution error

Action Typesโ€‹

PARAMETER SIMPLIFICATION

The API provides simplified parameters for common use cases. Advanced Brobot configuration options (search regions, verification options, repetition options) can be accessed through the Brobot CLI directly.

Click Actionโ€‹

Click on an image pattern or specific location.

Parameters

{
"action_type": "click",
"parameters": {
"image_pattern": "button.png", // OR use location
"location": {"x": 500, "y": 300},
"confidence": 0.9,
"click_type": "single", // single|double|right
"offset": {"x": 0, "y": 0}
}
}
ParameterTypeRequiredDescription
image_patternstringNo*Image file to find
locationobjectNo*Click coordinates
confidencefloatNoMin similarity (0.0-1.0)
click_typestringNoClick type (default: single)
offsetobjectNoOffset from pattern center

*Either image_pattern or location is required

Type Actionโ€‹

Type text at the current cursor location.

Parameters

{
"action_type": "type",
"parameters": {
"text": "Hello, World!",
"typing_speed": 300, // chars per minute
"clear_first": false,
"press_enter": true
}
}
ParameterTypeRequiredDescription
textstringYesText to type
typing_speedintegerNoTyping speed (default: 300)
clear_firstbooleanNoClear field first
press_enterbooleanNoPress Enter after typing

Drag Actionโ€‹

Drag from one location to another.

Parameters

{
"action_type": "drag",
"parameters": {
"start_pattern": "drag_handle.png", // OR start_x, start_y
"start_x": 100,
"start_y": 100,
"end_pattern": "drop_zone.png", // OR end_x, end_y
"end_x": 500,
"end_y": 500,
"duration": 1.0,
"button": "left" // left|right|middle
}
}
ParameterTypeRequiredDescription
start_patternstringNo*Start position pattern
start_x, start_yintegerNo*Start coordinates
end_patternstringNo*End position pattern
end_x, end_yintegerNo*End coordinates
durationfloatNoDrag duration (default: 1.0)
buttonstringNoMouse button (default: left)

*Either pattern or coordinates required for start/end

Find Actionโ€‹

Find an image pattern without performing any action.

Parameters

{
"action_type": "find",
"parameters": {
"image_pattern": "element.png",
"confidence": 0.9,
"timeout": 5.0
}
}
ParameterTypeRequiredDescription
image_patternstringYesImage file to find
confidencefloatNoMin similarity (0.0-1.0)
timeoutfloatNoSearch timeout (default: 5.0)
ADDITIONAL ACTION TYPES

The Brobot framework supports additional action types including vanish (wait for element to disappear), hover, double_click, right_click, and more. See the Brobot action documentation for the complete list.

Error Handlingโ€‹

Error Response Formatโ€‹

The API uses FastAPI's standard error response format:

Simple Errors (4xx, 5xx):

{
"detail": "Error message"
}

Validation Errors (422):

{
"detail": [
{
"loc": ["body", "field_name"],
"msg": "error description",
"type": "error_type"
}
]
}

Common Error Codesโ€‹

Status CodeDescriptionUsage
422Validation errorInvalid request parameters
500Internal server errorCLI errors, execution failures
ERROR HANDLING

The API currently uses simplified error responses. Future versions may include additional error context and custom error types.

Error Examplesโ€‹

Validation Error (422)

{
"detail": [
{
"loc": ["body", "action_type"],
"msg": "field required",
"type": "value_error.missing"
}
]
}

CLI Error (500)

{
"detail": "Brobot CLI error: Pattern not found",
"type": "cli_error",
"ctx": {
"pattern": "nonexistent.png",
"search_time": 5.0
}
}

Rate Limitingโ€‹

Future versions will implement rate limiting:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1642521600

Paginationโ€‹

Future versions will support pagination for large responses:

{
"data": [...],
"pagination": {
"page": 1,
"per_page": 20,
"total": 100,
"pages": 5
}
}

Webhooksโ€‹

Future versions will support webhooks for state changes:

{
"event": "state_changed",
"timestamp": "2024-01-20T10:30:00Z",
"data": {
"from_state": "login",
"to_state": "dashboard",
"trigger": "user_action"
}
}

Client Librariesโ€‹

Pythonโ€‹

from brobot_client import BrobotClient

client = BrobotClient("http://localhost:8000")
result = client.click("button.png")

JavaScript (Coming Soon)โ€‹

const client = new BrobotClient("http://localhost:8000");
await client.click("button.png");

cURL Examplesโ€‹

# Get observation
curl http://localhost:8000/api/v1/observation

# Execute click
curl -X POST http://localhost:8000/api/v1/execute \
-H "Content-Type: application/json" \
-d '{"action_type":"click","parameters":{"image_pattern":"button.png"}}'

# Pretty print with jq
curl http://localhost:8000/api/v1/state_structure | jq .

API Versioningโ€‹

The API uses URL versioning. Current version: v1

Future versions will maintain backwards compatibility or provide migration guides.

OpenAPI Specificationโ€‹

Access the OpenAPI (Swagger) specification:

Next Stepsโ€‹

After reviewing the API reference:

Supportโ€‹

COMMUNITY SUPPORT ONLY

Support for this experimental API is limited to community contributions. There are no guarantees of responses or fixes.