High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
docs: remove cli-commands.md and curl-commands.md - consolidate to api-reference.json
Marioc34e9a7ad0e4
diff --git a/docs/index.json b/docs/index.jsonindex 1870930a..e587a98a 100644--- a/docs/index.json+++ b/docs/index.json@@ -10,8 +10,6 @@"references": ["references/endpoints.md","references/configuration.md",- "references/cli-commands.md",- "references/curl-commands.md","references/api-reference.json"],"architecture": [diff --git a/docs/references/cli-commands.md b/docs/references/cli-commands.mddeleted file mode 100644index d4d9309a..00000000--- a/docs/references/cli-commands.md+++ /dev/null@@ -1,644 +0,0 @@-# CLI Reference--Complete reference for all `pinchtab` CLI commands. Requires a running PinchTab server (except for `help`).--## Quick Start--**Terminal 1: Start the server**-```bash-pinchtab-```--**Terminal 2: Use CLI commands**-```bash-pinchtab quick https://example.com # Navigate + analyze page-```--## Server Control--Start Pinchtab in different modes.--### Start Server-```bash-pinchtab-```-Launches Pinchtab server on `http://127.0.0.1:9867` (default).--**Options:**-```bash-BRIDGE_PORT=9868 pinchtab # Custom port-BRIDGE_HEADLESS=false pinchtab # Visible window-BRIDGE_PROFILE=/path/to/profile pinchtab # Custom profile-BRIDGE_TOKEN=secret pinchtab # Enable auth-```--### Dashboard (Profile Manager)-```bash-pinchtab dashboard-```-Run the orchestrator and profile manager (no browser).--### Connect to Running Profile-```bash-pinchtab connect <name>-```-Get the URL for a running Chrome profile.-------## CLI Commands (Require Running Server)--### Quick Start Command--#### Navigate + Analyze Page-```bash-pinchtab quick <url>-```-**New beginner-friendly command that combines navigation and page analysis in one step.**--- Navigates to the URL-- Waits for page to load-- Shows page structure with clickable elements-- Suggests next actions (click, type, screenshot, PDF)--**Example:**-```bash-$ pinchtab quick https://example.com-π¦ Navigating to https://example.com ...--π Page structure:-[accessible tree output]--π Title: Example Domain-π URL: https://example.com/--π‘ Quick actions:- pinchtab click <ref> # Click an element (use refs from above)- pinchtab type <ref> <text> # Type into input field- pinchtab screenshot # Take a screenshot- pinchtab pdf -o output.pdf # Save as PDF-```-------### Navigation--#### Navigate to URL-```bash-pinchtab nav <url>-pinchtab navigate <url> # Alias-```--**Options:**-```bash-pinchtab nav https://example.com --new-tab-pinchtab nav https://example.com --block-images-pinchtab nav https://example.com --block-ads-```--**Flags:**-- `--new-tab` β Open in new tab instead of current-- `--block-images` β Don't load images-- `--block-ads` β Block 100+ tracking/ad domains--**Example:**-```bash-pinchtab nav https://example.com-# Returns: {"title": "Example Domain", "url": "https://example.com"}-```-------### Snapshots & DOM--#### Get Accessibility Tree-```bash-pinchtab snap-pinchtab snapshot # Alias-```--**Options:**-```bash-# Interactive only (buttons, links, inputs)-pinchtab snap -i--# Compact format (most token-efficient)-pinchtab snap -c--# Diff only (changes since last snapshot)-pinchtab snap -d--# Combine flags-pinchtab snap -i -c--# CSS selector scope-pinchtab snap -s "main > form"--# Truncate to ~1000 tokens-pinchtab snap --max-tokens 1000--# Max tree depth-pinchtab snap --depth 3--# Target specific tab-pinchtab snap --tab <tabId>-```--**Flags:**-- `-i, --interactive` β Only buttons, links, inputs (faster, fewer tokens)-- `-c, --compact` β Compact JSON format (most token-efficient for AI)-- `-d, --diff` β Only elements that changed since last snapshot-- `-s, --selector CSS` β Scope to CSS selector-- `--max-tokens N` β Truncate output to ~N tokens-- `--depth N` β Max tree depth-- `--tab ID` β Target specific tab (default: first tab)--**Output Structure:**-```json-{- "elements": [- {- "ref": "e0",- "role": "heading",- "name": "Example Domain",- "visible": true- },- {- "ref": "e1",- "role": "link",- "name": "More information...",- "visible": true- }- ]-}-```-------### Interaction--#### Click Element-```bash-pinchtab click <ref>-```--**Example:**-```bash-# Click element with ref e5-pinchtab click e5-```--#### Type Text-```bash-pinchtab type <ref> <text>-```--**Example:**-```bash-pinchtab type e12 "hello world"-pinchtab type e3 "[email protected]"-```--#### Fill Input (Direct)-```bash-pinchtab fill <ref|selector> <text>-```-Sets input value directly without triggering key events.--**Example:**-```bash-pinchtab fill e5 "value"-pinchtab fill "input[name='email']" "[email protected]"-```--#### Press Key-```bash-pinchtab press <key>-```--**Keys:** `Enter`, `Tab`, `Escape`, `Backspace`, `Delete`, `ArrowUp`, `ArrowDown`, `ArrowLeft`, `ArrowRight`, etc.--**Example:**-```bash-pinchtab press Enter-pinchtab press Tab-pinchtab press Escape-```--#### Hover Element-```bash-pinchtab hover <ref>-```--**Example:**-```bash-pinchtab hover e5-```--#### Focus Element-```bash-pinchtab focus <ref>-```--**Example:**-```bash-pinchtab focus e5-```--#### Scroll-```bash-pinchtab scroll <ref|pixels>-```--Scroll to element or by pixel amount.--**Example:**-```bash-pinchtab scroll e5 # Scroll to element-pinchtab scroll 500 # Scroll down 500px-```--#### Select Dropdown-```bash-pinchtab select <ref> <value>-```--**Example:**-```bash-pinchtab select e7 "Option 2"-```-------### Content Extraction--#### Extract Text-```bash-pinchtab text-pinchtab text --raw # Raw innerText (no readability)-```--**Modes:**-- Default β Readability extraction (strips nav, ads, sidebars)-- `--raw` β Raw `innerText` (full page text)--**Example:**-```bash-pinchtab text # Returns readable article/content-pinchtab text --raw # Returns all text on page-pinchtab text | jq .text # Pipe output to jq-```--#### Evaluate JavaScript-```bash-pinchtab eval <expression>-pinchtab evaluate <expression> # Alias-```--**Escape hatch to run any JavaScript.**--**Example:**-```bash-pinchtab eval "document.title"-pinchtab eval "document.querySelectorAll('a').length"-pinchtab eval "localStorage.getItem('token')"-```-------### Capture & Export--#### Screenshot-```bash-pinchtab ss-pinchtab screenshot # Alias-```--**Options:**-```bash-pinchtab ss -o screenshot.jpg-pinchtab ss -q 85 # Quality 0-100 (default: 90)-pinchtab ss -o page.jpg -q 80-```--**Flags:**-- `-o, --output FILE` β Save to file (default: stdout)-- `-q, --quality N` β JPEG quality 0-100 (default: 90)--**Example:**-```bash-pinchtab ss -o page.jpg-pinchtab ss -o page.jpg -q 75-```--#### Export PDF-```bash-pinchtab pdf-pinchtab pdf -o output.pdf-```--**Basic Options:**-```bash-pinchtab pdf -o output.pdf-pinchtab pdf -o report.pdf --landscape-pinchtab pdf -o report.pdf --scale 1.5-pinchtab pdf -o report.pdf --page-ranges "1-3,5"-```--**Paper & Margins:**-```bash-pinchtab pdf --paper-width 8.5 --paper-height 11 # US Letter (default)-pinchtab pdf --paper-width 210 --paper-height 297 # A4 (in mm)-pinchtab pdf --margin-top 0.5 --margin-bottom 0.5-pinchtab pdf --margin-left 1.0 --margin-right 1.0-pinchtab pdf --prefer-css-page-size # Honor CSS @page size-```--**Headers & Footers:**-```bash-pinchtab pdf --display-header-footer-pinchtab pdf --header-template "<div>Page <span class='pageNumber'></span></div>"-pinchtab pdf --footer-template "<div>Β© 2024</div>"-```--**Accessibility:**-```bash-pinchtab pdf --generate-tagged-pdf # Create accessible PDF-pinchtab pdf --generate-document-outline # Add document outline/bookmarks-```--**File Output:**-```bash-pinchtab pdf --file-output # Save to server disk-pinchtab pdf --file-output --path /tmp/output.pdf-```--**All Options:**-```bash-pinchtab pdf -o output.pdf \- --landscape \- --paper-width 8.5 \- --paper-height 11 \- --margin-top 0.5 \- --margin-bottom 0.5 \- --margin-left 1.0 \- --margin-right 1.0 \- --scale 1.0 \- --page-ranges "1-5" \- --prefer-css-page-size \- --display-header-footer \- --header-template "<h1>Report</h1>" \- --footer-template "<p>Page <span class='pageNumber'></span></p>" \- --generate-tagged-pdf \- --generate-document-outline \- --tab tabId123-```-------### Tab Management--#### List Tabs-```bash-pinchtab tabs-pinchtab tab # Alias-```--**Returns:** JSON array of open tabs with `tabId`, `title`, `url`.--**Example:**-```bash-$ pinchtab tabs-[- {- "tabId": "abc123",- "title": "Example Domain",- "url": "https://example.com"- }-]-```--#### Open New Tab-```bash-pinchtab tabs new <url>-pinchtab tab new <url> # Alias-```--**Example:**-```bash-pinchtab tabs new https://google.com-```--#### Close Tab-```bash-pinchtab tabs close <tabId>-pinchtab tab close <tabId> # Alias-```--**Example:**-```bash-pinchtab tabs close abc123-```-------### Server & Help--#### Health Check-```bash-pinchtab health-```--**Example:**-```bash-$ pinchtab health-{- "status": "ok",- "version": "0.7.6",- "uptime": 3600-}-```--#### Show Help-```bash-pinchtab help-```--Displays all commands and options.-------## Environment Variables--Configure Pinchtab behavior via environment variables.--### Client Variables-Used by CLI commands:--```bash-PINCHTAB_URL=http://localhost:9867 # Server URL (default: http://127.0.0.1:9867)-PINCHTAB_TOKEN=your-secret-token # Auth token (sent as Bearer)-```--### Server Variables-Used when running `pinchtab` server:--```bash-BRIDGE_PORT=9867 # Server port (default: 9867)-BRIDGE_BIND=0.0.0.0 # Bind address (default: 127.0.0.1)-BRIDGE_HEADLESS=true # Headless mode (default: true)-BRIDGE_PROFILE=/path/to/profile # Chrome profile directory-BRIDGE_TOKEN=your-secret-token # API auth token-BRIDGE_BLOCK_ADS=true # Block 100+ ad domains-BRIDGE_NO_RESTORE=false # Don't restore tabs on startup-CDP_URL=http://localhost:9222 # Connect to external Chrome (instead of launching)-```-------## Examples--### Basic Workflow-```bash-# Terminal 1: Start server-pinchtab--# Terminal 2: Interact-pinchtab nav https://example.com-pinchtab snap -i -c # See interactive elements-pinchtab click e5 # Click element-pinchtab snap # Verify change-pinchtab screenshot -o result.jpg # Capture result-```--### Form Filling-```bash-pinchtab nav https://example.com/form-pinchtab snap -i -c # Find input refs-pinchtab click e1 # Focus first field-pinchtab type e1 "John Doe" # Type name-pinchtab click e2 # Focus email field-pinchtab type e2 "[email protected]" # Type email-pinchtab click e5 # Click submit-pinchtab snap # Verify submission-```--### Scraping with Text Extraction-```bash-pinchtab nav https://example.com/article-pinchtab text > article.txt # Extract text-pinchtab text | jq .text # Parse JSON-```--### PDF Generation-```bash-pinchtab nav https://example.com/report-pinchtab pdf -o report.pdf \- --landscape \- --page-ranges "1-5" \- --display-header-footer \- --header-template "<h1>Report</h1>"-```--### Multi-Tab Automation-```bash-pinchtab nav https://google.com-pinchtab tabs new https://github.com-pinchtab tabs # List both tabs-pinchtab snap --tab tab2 # Snapshot second tab-```--### With Authentication-```bash-PINCHTAB_TOKEN=secret-token pinchtab nav https://api.example.com-PINCHTAB_URL=http://192.168.1.100:9867 pinchtab snap-```--### Piping with jq-```bash-# Get all links on page-pinchtab snap -i -c | jq '.elements[] | select(.role=="link") | {ref, name}'--# Extract readable text as JSON-pinchtab text | jq '.text'--# List all tabs-pinchtab tabs | jq '.[] | {tabId, title, url}'-```-------## Tips--### Token Efficiency-For AI agents, use flags to reduce token usage:--```bash-pinchtab snap -i -c --max-tokens 1000 # Interactive, compact, truncated-pinchtab text --raw # Raw text instead of readability-```--### Error Messages-If server isn't running:-```-β Pinchtab server is not running on http://localhost:9867--To start the server:- pinchtab # Run in foreground- pinchtab & # Run in background-```--### Headless vs Headed-```bash-pinchtab # Headless (default, no window)-BRIDGE_HEADLESS=false pinchtab # Headed (visible window)-```--### Profile Management-```bash-BRIDGE_PROFILE=~/.pinchtab/profile1 pinchtab # Custom profile-BRIDGE_NO_RESTORE=true pinchtab # Start fresh-```-------## Command Reference (Alphabetical)--| Command | Description |-|---------|-------------|-| `click <ref>` | Click element |-| `connect <name>` | Get URL for running profile |-| `dashboard` | Start profile manager |-| `eval <expr>` | Evaluate JavaScript |-| `fill <ref\|selector> <text>` | Set input value |-| `focus <ref>` | Focus element |-| `health` | Check server status |-| `help` | Show help text |-| `hover <ref>` | Hover over element |-| `nav <url>` | Navigate to URL |-| `pdf [-o file]` | Export page as PDF |-| `press <key>` | Press key |-| `quick <url>` | Navigate + analyze (quick start) |-| `screenshot` / `ss` | Take screenshot |-| `scroll <ref\|px>` | Scroll page |-| `select <ref> <val>` | Select dropdown |-| `snap` / `snapshot` | Get accessibility tree |-| `tab[s]` | List/manage tabs |-| `text` | Extract readable text |-| `type <ref> <text>` | Type into element |-------## Aliases--| Command | Alias |-|---------|-------|-| `nav` | `navigate` |-| `snap` | `snapshot` |-| `ss` | `screenshot` |-| `eval` | `evaluate` |-| `tab` | `tabs` |-------**For more help:** `pinchtab help`diff --git a/docs/references/curl-commands.md b/docs/references/curl-commands.mddeleted file mode 100644index d056b3cd..00000000--- a/docs/references/curl-commands.md+++ /dev/null@@ -1,818 +0,0 @@-# Curl Reference--Complete HTTP API reference. Use `curl` or any HTTP client to interact with the API directly.--## Quick Start--**Terminal 1: Start server**-```bash-pinchtab-```--**Terminal 2: Make API calls**-```bash-curl http://localhost:9867/health-curl -X POST http://localhost:9867/navigate -H "Content-Type: application/json" -d '{"url":"https://example.com"}'-curl http://localhost:9867/snapshot-```--## Base URL--```-http://127.0.0.1:9867-http://localhost:9867-```--With authentication:-```bash-curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:9867/health-```-------## Health & Status--### Health Check-```bash-curl http://localhost:9867/health-```--**Response:**-```json-{- "status": "ok",- "version": "0.7.6",- "uptime": 3600-}-```-------## Navigation--### Navigate to URL-```bash-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://example.com"}'-```--**Request body:**-```json-{- "url": "https://example.com",- "newTab": false,- "blockImages": false,- "blockAds": false-}-```--**Query parameters:**-- `url` (required) β URL to navigate to-- `newTab` β Open in new tab (default: false)-- `blockImages` β Don't load images (default: false)-- `blockAds` β Block ad domains (default: false)--**Response:**-```json-{- "title": "Example Domain",- "url": "https://example.com",- "tabId": "abc123",- "targetId": "target-1"-}-```--**Examples:**-```bash-# Navigate to URL-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://google.com"}'--# Open in new tab-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://github.com","newTab":true}'--# Block ads and images-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://example.com","blockAds":true,"blockImages":true}'-```-------## Snapshots & DOM--### Get Accessibility Tree-```bash-curl http://localhost:9867/snapshot-```--**Query parameters:**-- `filter` β `interactive` (buttons, links, inputs only)-- `format` β `compact` or `text` (default: full JSON)-- `diff` β `true` (only changes since last snapshot)-- `selector` β CSS selector to scope to-- `maxTokens` β Truncate to ~N tokens-- `depth` β Max tree depth (default: unlimited)-- `tabId` β Target specific tab--**Examples:**-```bash-# Full snapshot-curl http://localhost:9867/snapshot--# Interactive elements only (most token-efficient)-curl http://localhost:9867/snapshot?filter=interactive--# Compact format-curl http://localhost:9867/snapshot?format=compact--# Compact + interactive-curl http://localhost:9867/snapshot?filter=interactive&format=compact--# Diff only (changes since last snapshot)-curl http://localhost:9867/snapshot?diff=true--# Scope to CSS selector-curl http://localhost:9867/snapshot?selector=main%20form--# Limit tokens-curl http://localhost:9867/snapshot?maxTokens=1000--# Specific tab-curl http://localhost:9867/snapshot?tabId=abc123--# Combine filters-curl "http://localhost:9867/snapshot?filter=interactive&format=compact&maxTokens=500"-```--**Response:**-```json-{- "elements": [- {- "ref": "e0",- "role": "heading",- "name": "Example Domain",- "visible": true- },- {- "ref": "e1",- "role": "link",- "name": "More information...",- "href": "https://www.iana.org/domains/example"- }- ]-}-```-------## Interaction--### Click Element-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"click","ref":"e5"}'-```--**Query parameters:**-- `tabId` β Target specific tab--**Examples:**-```bash-# Click element-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"click","ref":"e5"}'--# Click on specific tab-curl -X POST "http://localhost:9867/action?tabId=abc123" \- -H "Content-Type: application/json" \- -d '{"kind":"click","ref":"e5"}'-```--### Type Text-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"type","ref":"e12","text":"hello world"}'-```--**Examples:**-```bash-# Type into input-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"type","ref":"e3","text":"[email protected]"}'--# Type with special characters (JSON escaped)-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"type","ref":"e5","text":"Hello \"World\"!"}'-```--### Fill Input (Direct)-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"fill","ref":"e5","text":"value"}'-```--Sets input value directly without triggering key events.--**Examples:**-```bash-# Fill input by ref-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"fill","ref":"e5","text":"hello"}'--# Fill by selector-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"fill","selector":"input[name=email]","text":"[email protected]"}'-```--### Press Key-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"press","key":"Enter"}'-```--**Keys:** `Enter`, `Tab`, `Escape`, `Backspace`, `Delete`, `ArrowUp`, `ArrowDown`, `ArrowLeft`, `ArrowRight`, etc.--**Examples:**-```bash-# Press Enter-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"press","key":"Enter"}'--# Press Escape-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"press","key":"Escape"}'--# Press Tab-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"press","key":"Tab"}'-```--### Hover Element-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"hover","ref":"e5"}'-```--### Focus Element-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"focus","ref":"e5"}'-```--### Scroll-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"scroll","ref":"e5"}'-```--Or scroll by pixels:-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"scroll","pixels":500}'-```--### Select Dropdown-```bash-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"select","ref":"e7","value":"Option 2"}'-```-------## Content Extraction--### Extract Text-```bash-curl http://localhost:9867/text-```--**Query parameters:**-- `mode` β `raw` (raw innerText) or default (readability extraction)-- `tabId` β Target specific tab--**Examples:**-```bash-# Extract readable text-curl http://localhost:9867/text--# Raw innerText (full page)-curl http://localhost:9867/text?mode=raw--# From specific tab-curl "http://localhost:9867/text?tabId=abc123"-```--**Response:**-```json-{- "text": "Example Domain\nThis domain is for use in examples...",- "length": 1234-}-```--### Evaluate JavaScript-```bash-curl -X POST http://localhost:9867/execute \- -H "Content-Type: application/json" \- -d '{"expression":"document.title"}'-```--**Query parameters:**-- `tabId` β Target specific tab--**Examples:**-```bash-# Get page title-curl -X POST http://localhost:9867/execute \- -H "Content-Type: application/json" \- -d '{"expression":"document.title"}'--# Count links-curl -X POST http://localhost:9867/execute \- -H "Content-Type: application/json" \- -d '{"expression":"document.querySelectorAll(\"a\").length"}'--# Get localStorage value-curl -X POST http://localhost:9867/execute \- -H "Content-Type: application/json" \- -d '{"expression":"localStorage.getItem(\"token\")"}'--# Complex expression-curl -X POST http://localhost:9867/execute \- -H "Content-Type: application/json" \- -d '{"expression":"JSON.stringify({title: document.title, url: location.href})"}'-```--**Response:**-```json-{- "result": "Example Domain"-}-```-------## Capture & Export--### Screenshot-```bash-curl http://localhost:9867/screenshot -o screenshot.jpg-```--**Query parameters:**-- `quality` β JPEG quality 0-100 (default: 90)-- `tabId` β Target specific tab--**Examples:**-```bash-# Screenshot to file-curl http://localhost:9867/screenshot -o page.jpg--# With quality-curl "http://localhost:9867/screenshot?quality=75" -o page.jpg--# Specific tab-curl "http://localhost:9867/screenshot?tabId=abc123" -o page.jpg--# To stdout (view metadata)-curl http://localhost:9867/screenshot-```--**Response (if no output file):**-```json-{- "data": "data:image/jpeg;base64,/9j/4AAQSkZJRg...",- "size": 12345,- "mimeType": "image/jpeg"-}-```--### Export PDF-```bash-curl http://localhost:9867/pdf -o output.pdf-```--**Query parameters:**-- `output` β Output format: `json` (data URL) or `file` (filename)-- `path` β Custom file path (with `output=file`)-- `landscape` β `true` for landscape-- `paperWidth` β Width in inches (default: 8.5)-- `paperHeight` β Height in inches (default: 11)-- `marginTop`, `marginBottom`, `marginLeft`, `marginRight` β Margins in inches-- `scale` β Print scale 0.1-2.0 (default: 1.0)-- `pageRanges` β Pages to export (e.g., "1-3,5")-- `preferCSSPageSize` β `true` to honor CSS @page size-- `displayHeaderFooter` β `true` to show header/footer-- `headerTemplate` β HTML template for header-- `footerTemplate` β HTML template for footer-- `generateTaggedPDF` β `true` for accessible PDF-- `generateDocumentOutline` β `true` for document outline-- `tabId` β Target specific tab--**Examples:**-```bash-# Basic PDF-curl http://localhost:9867/pdf -o output.pdf--# Landscape-curl "http://localhost:9867/pdf?landscape=true" -o output.pdf--# Custom paper size-curl "http://localhost:9867/pdf?paperWidth=8.5&paperHeight=11&marginTop=0.5&marginBottom=0.5" -o output.pdf--# Page ranges-curl "http://localhost:9867/pdf?pageRanges=1-3,5" -o output.pdf--# With header and footer-curl "http://localhost:9867/pdf?displayHeaderFooter=true&headerTemplate=%3Cdiv%3EReport%3C%2Fdiv%3E&footerTemplate=%3Cdiv%3EPage%20%3Cspan%20class=%27pageNumber%27%3E%3C%2Fspan%3E%3C%2Fdiv%3E" -o output.pdf--# Accessible PDF-curl "http://localhost:9867/pdf?generateTaggedPDF=true&generateDocumentOutline=true" -o output.pdf--# Save to server disk-curl "http://localhost:9867/pdf?output=file&path=/tmp/report.pdf" -o output.pdf--# All options combined-curl "http://localhost:9867/pdf?landscape=true&paperWidth=8.5&paperHeight=11&marginTop=0.5&marginBottom=0.5&scale=1.0&pageRanges=1-5&displayHeaderFooter=true&generateTaggedPDF=true" -o report.pdf-```--**Response (output=json):**-```json-{- "data": "data:application/pdf;base64,JVBERi0xLjQ...",- "size": 45678-}-```--**Response (output=file):**-```json-{- "path": "/tmp/report.pdf",- "size": 45678,- "message": "PDF saved to disk"-}-```-------## Tab Management--### List All Tabs-```bash-curl http://localhost:9867/tabs-```--**Response:**-```json-{- "tabs": [- {- "id": "abc123",- "url": "https://example.com",- "title": "Example Domain",- "type": "page"- },- {- "id": "def456",- "url": "https://github.com",- "title": "GitHub",- "type": "page"- }- ]-}-```--### Create New Tab-```bash-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://google.com","newTab":true}'-```--**Response:**-```json-{- "title": "Google",- "url": "https://www.google.com",- "tabId": "ghi789",- "targetId": "target-2"-}-```--### Close Tab-```bash-curl -X DELETE http://localhost:9867/tabs/abc123-```--**Query parameters:**-- `tabId` β Tab to close--**Examples:**-```bash-# Close specific tab-curl -X DELETE http://localhost:9867/tabs/abc123--# Or use query parameter-curl -X DELETE "http://localhost:9867/tabs?tabId=abc123"-```--### Tab Locking (Multi-Agent Coordination)--#### Lock Tab-```bash-curl -X POST http://localhost:9867/tab/lock \- -H "Content-Type: application/json" \- -d '{"tabId":"abc123","owner":"agent-1","ttlSeconds":60}'-```--**Response:**-```json-{- "tabId": "abc123",- "owner": "agent-1",- "lockedUntil": "2024-02-27T15:40:00Z"-}-```--#### Unlock Tab-```bash-curl -X POST http://localhost:9867/tab/unlock \- -H "Content-Type: application/json" \- -d '{"tabId":"abc123","owner":"agent-1"}'-```-------## Complete Workflow Examples--### Example 1: Form Filling-```bash-# Navigate to form-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://example.com/form"}'--# Get form structure-curl http://localhost:9867/snapshot?filter=interactive--# Fill first field (email)-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"fill","ref":"e1","text":"[email protected]"}'--# Fill second field (password)-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"fill","ref":"e2","text":"mypassword"}'--# Click submit button-curl -X POST http://localhost:9867/action \- -H "Content-Type: application/json" \- -d '{"kind":"click","ref":"e5"}'--# Verify submission-curl http://localhost:9867/snapshot-curl http://localhost:9867/screenshot -o result.jpg-```--### Example 2: Scraping with Text Extraction-```bash-# Navigate-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://example.com/article"}'--# Wait a moment-sleep 2--# Extract readable text-curl http://localhost:9867/text > article.json--# Parse with jq-curl http://localhost:9867/text | jq '.text'-```--### Example 3: Multi-Tab Automation-```bash-# Navigate to first site-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://google.com"}' > tab1.json--# Get tab ID from response-TAB1=$(jq -r '.tabId' tab1.json)--# Open second tab-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://github.com","newTab":true}' > tab2.json--TAB2=$(jq -r '.tabId' tab2.json)--# Snapshot first tab-curl "http://localhost:9867/snapshot?tabId=$TAB1"--# Snapshot second tab-curl "http://localhost:9867/snapshot?tabId=$TAB2"-```--### Example 4: PDF Report Generation-```bash-# Navigate to page-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://example.com/report"}'--# Generate PDF with custom header-curl "http://localhost:9867/pdf?displayHeaderFooter=true&headerTemplate=%3Cdiv%3EMonthly%20Report%3C%2Fdiv%3E&footerTemplate=%3Cdiv%3EPage%20%3Cspan%20class=%27pageNumber%27%3E%3C%2Fspan%3E%3C%2Fdiv%3E&landscape=true&pageRanges=1-10" -o report.pdf-```--### Example 5: JavaScript Evaluation-```bash-# Navigate-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://example.com"}'--# Get page metadata-curl -X POST http://localhost:9867/execute \- -H "Content-Type: application/json" \- -d '{"expression":"JSON.stringify({title: document.title, url: location.href, links: document.querySelectorAll(\"a\").length})"}'-```-------## Authentication--If your server requires authentication, add the `Authorization` header:--```bash-curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:9867/health--curl -H "Authorization: Bearer YOUR_TOKEN" \- -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d '{"url":"https://example.com"}'-```--Set via environment variable:-```bash-TOKEN="your-secret-token"-curl -H "Authorization: Bearer $TOKEN" http://localhost:9867/health-```--Or use curl's `-u` flag (basic auth):-```bash-curl -u token:password http://localhost:9867/health-```-------## Error Handling--### Common Error Responses--**400 Bad Request**-```json-{- "error": "invalid request body"-}-```--**404 Not Found**-```json-{- "error": "tab not found"-}-```--**401 Unauthorized**-```json-{- "error": "missing or invalid token"-}-```--**500 Server Error**-```json-{- "error": "internal server error"-}-```--### Using with jq for Error Handling-```bash-# Check response and extract error-curl -s http://localhost:9867/snapshot | jq '.error // .'--# Check HTTP status code-curl -w "%{http_code}" http://localhost:9867/health-```-------## Tips--### URL Encoding-Remember to URL-encode query parameters:--```bash-# Selector with spaces-curl "http://localhost:9867/snapshot?selector=main%20form"--# HTML in footer template-curl "http://localhost:9867/pdf?headerTemplate=%3Cdiv%3EReport%3C%2Fdiv%3E"--# Use jq to help with JSON escaping-TEMPLATE="<div>Page <span class='pageNumber'></span></div>"-curl -X POST http://localhost:9867/pdf \- --data-urlencode "footerTemplate=$TEMPLATE"-```--### Piping with jq-```bash-# Extract page title-curl http://localhost:9867/execute \- -d '{"expression":"document.title"}' | jq '.result'--# Get all clickable elements-curl http://localhost:9867/snapshot?filter=interactive | jq '.elements[] | select(.role=="button" or .role=="link")'--# Count elements-curl http://localhost:9867/snapshot | jq '.elements | length'-```--### Using curl with Files-```bash-# Save response to file-curl http://localhost:9867/screenshot -o page.jpg--# Load JSON from file-curl -X POST http://localhost:9867/navigate \- -H "Content-Type: application/json" \- -d @request.json--# Request file example (request.json):-# {"url":"https://example.com","blockAds":true}-```--### Debugging-```bash-# Show request headers-curl -v http://localhost:9867/health--# Show response headers only-curl -i http://localhost:9867/health--# Pretty-print JSON response-curl http://localhost:9867/snapshot | jq .--# Save full response with headers-curl -D response-headers.txt http://localhost:9867/health-```-------## API Endpoints Summary--| Method | Endpoint | Description |-|--------|----------|-------------|-| `GET` | `/health` | Health check |-| `POST` | `/navigate` | Navigate to URL |-| `GET` | `/snapshot` | Get accessibility tree |-| `POST` | `/action` | Interact (click, type, etc.) |-| `GET` | `/text` | Extract readable text |-| `POST` | `/execute` | Evaluate JavaScript |-| `GET` | `/screenshot` | Take screenshot |-| `GET` | `/pdf` | Export PDF |-| `GET` | `/tabs` | List tabs |-| `DELETE` | `/tabs/:id` | Close tab |-| `POST` | `/tab/lock` | Lock tab for agent |-| `POST` | `/tab/unlock` | Unlock tab |-------**For CLI commands:** See [`docs/cli-commands.md`](cli-commands.md)