# API Getting Started

Source: https://metadock.app/api-docs/getting-started

## Introduction

MetaDock provides five ways to automate browsers: REST API, WebSocket API, Selenium WebDriver (W3C), Chrome DevTools Protocol (CDP), and MCP integration. MetaDock shows all browsers running in a visual grid — you can watch your automation execute in real-time.

### REST API

HTTP endpoints for browser control. Works with any language.

MetaDock+

### WebSocket API

Real-time bidirectional communication and event subscriptions.

MetaDock Pro only

### Selenium WebDriver

W3C WebDriver protocol. Use existing scripts with minimal changes.

MetaDock+

### MCP Integration

Control browsers with AI assistants using natural language.

## Authentication

All MetaDock APIs share a single API key (UUID). Find it in the MetaDock app under Settings → API. This key works for REST API, WebSocket, Selenium WebDriver, and MCP.

### Authentication Methods

Authorization: Bearer <api\_key>

Recommended. Standard Bearer token in Authorization header.

X-Api-Key: <api\_key>

Alternative header-based authentication.

```
import requests

API_KEY = "your-uuid-from-metadock-settings"
BASE_URL = "http://127.0.0.1:8080"

# Method 1: Bearer Token (Recommended)
headers = {"Authorization": f"Bearer {API_KEY}"}
response = requests.get(f"{BASE_URL}/api/browsers", headers=headers)

# Method 2: X-Api-Key Header
headers = {"X-Api-Key": API_KEY}
response = requests.get(f"{BASE_URL}/api/browsers", headers=headers)
```

## Base URLs

### REST API

`http://127.0.0.1:8080`

All REST endpoints are prefixed with /api/

### WebSocket API

`ws://127.0.0.1:8080/ws`

Single WebSocket endpoint for all operations

### Selenium WebDriver

`http://127.0.0.1:8080/wd/hub`

W3C WebDriver protocol endpoint

## Response Formats

### REST API Success Response

JSON

```
{
  "success": true,
  "data": {
    "uuid": "browser-abc-123",
    "url": "https://example.com",
    "title": "Example Domain"
  },
  "timestamp": "2025-01-04T12:00:00"
}
```

### REST API Error Response

JSON

```
{
  "success": false,
  "error": "Browser not found",
  "timestamp": "2025-01-04T12:00:00"
}
```

### WebSocket Response

JSON

```
{
  "type": "response",
  "success": true,
  "data": { ... },
  "id": 1,
  "timestamp": "2025-01-04T12:00:00"
}
```

### WebDriver Response (W3C)

JSON

```
{
  "value": {
    "sessionId": "session-xyz-789",
    "capabilities": { ... }
  }
}
```
