Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Feature/cloud docs (#522)
Gregor Žunič2080ed338d69
diff --git a/docs/cloud/implementation.mdx b/docs/cloud/implementation.mdxnew file mode 100644index 000000000..48dfa067d--- /dev/null+++ b/docs/cloud/implementation.mdx@@ -0,0 +1,85 @@+---+title: "Implementing the API"+description: "Learn how to implement the Browser Use API in Python"+icon: "code"+---++This guide shows how to implement common API patterns using Python. We'll create a complete example that creates and monitors a browser automation task.++## Basic Implementation++Here's a simple implementation using Python's `requests` library:++```python+import requests+import time++API_KEY = "your_api_key_here"+BASE_URL = "https://api.browser-use.com/api/v1"+HEADERS = {"Authorization": f"Bearer {API_KEY}"}++def create_task(instructions):+ """Create a new browser automation task"""+ response = requests.post(+ f"{BASE_URL}/run-task",+ headers=HEADERS,+ json={"task": instructions}+ )+ return response.json()["id"]++def get_task_status(task_id):+ """Get current task status"""+ response = requests.get(+ f"{BASE_URL}/task/{task_id}/status",+ headers=HEADERS+ )+ return response.json()++def get_task_details(task_id):+ """Get full task details including output"""+ response = requests.get(+ f"{BASE_URL}/task/{task_id}",+ headers=HEADERS+ )+ return response.json()++def wait_for_completion(task_id, poll_interval=2):+ """Poll task status until completion"""+ while True:+ status = get_task_status(task_id)+ if status in ["finished", "failed", "stopped"]:+ return get_task_details(task_id)+ time.sleep(poll_interval)+```++## Task Control Example++Here's how to implement task control with pause/resume functionality:++```python+def control_task():+ # Create a new task+ task_id = create_task("Go to google.com and search for Browser Use")++ # Wait for 5 seconds+ time.sleep(5)++ # Pause the task+ requests.put(f"{BASE_URL}/pause-task?task_id={task_id}", headers=HEADERS)+ print("Task paused! Check the live preview.")++ # Wait for user input+ input("Press Enter to resume...")++ # Resume the task+ requests.put(f"{BASE_URL}/resume-task?task_id={task_id}", headers=HEADERS)++ # Wait for completion+ result = wait_for_completion(task_id)+ print(f"Task completed with output: {result['output']}")+```++<Note>+ Remember to handle your API key securely and implement proper error handling+ in production code.+</Note>diff --git a/docs/cloud/quistart.mdx b/docs/cloud/quistart.mdxnew file mode 100644index 000000000..ffbafb9f7--- /dev/null+++ b/docs/cloud/quistart.mdx@@ -0,0 +1,103 @@+---+title: "Quickstart"+description: "Learn how to get started with the Browser Use Cloud API"+icon: "cloud"+---++The Browser Use Cloud API lets you create and manage browser automation agents programmatically. Each agent can execute tasks and provide real-time feedback through a live preview URL.++## Prerequisites++<Note>+ You need an active subscription and an API key from+ [cloud.browser-use.com/billing](https://cloud.browser-use.com/billing)+</Note>++## Pricing++The Browser Use Cloud API is priced at <b>$0.05 per step</b> that agent executes.++<Note>+ Since Browser Use has the ability to execute multiple steps at the same time,+ the price for filling out forms much lower than other services.+</Note>++## Creating Your First Agent++Create a new browser automation task by providing instructions in natural language:++```bash+curl -X POST https://api.browser-use.com/api/v1/run-task \+ -H "Authorization: Bearer your_api_key_here" \+ -H "Content-Type: application/json" \+ -d '{+ "task": "Go to google.com and search for Browser Use"+ }'+```++The API returns a task ID that you can use to manage the task and check the live preview URL.++<Note>+ The task response includes a `live_url` that you can embed in an iframe to+ watch and control the agent in real-time.+</Note>++## Managing Tasks++Control running tasks with these operations:++<AccordionGroup>+ <Accordion title="Pause/Resume Tasks">+ Temporarily pause task execution with [`/api/v1/pause-task`](/cloud/api-v1/pause-task) and resume with+ [`/api/v1/resume-task`](/cloud/api-v1/resume-task). Useful for manual inspection or intervention.+ </Accordion>++ <Accordion title="Stop Tasks">+ Permanently stop a task using [`/api/v1/stop-task`](/cloud/api-v1/stop-task). The task cannot be+ resumed after being stopped.+ </Accordion>+</AccordionGroup>++For detailed API documentation, see the tabs on the left, which includes the full coverage of the API.++## Building your own client (OpenAPI)++<Note>+ We recommend this only if you don't need control and only need to run simple+ tasks.+</Note>++The best way to build your own client is to use our [OpenAPI specification](http://api.browser-use.com/openapi.json) to generate a type-safe client library.++### Python++Use [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) to generate a modern Python client:++```bash+# Install the generator+pipx install openapi-python-client --include-deps++# Generate the client+openapi-python-client generate --url http://api.browser-use.com/openapi.json+```++This will create a Python package with full type hints, modern dataclasses, and async support.++### TypeScript/JavaScript++For TypeScript projects, use [openapi-typescript](https://www.npmjs.com/package/openapi-typescript) to generate type definitions:++```bash+# Install the generator+npm install -D openapi-typescript++# Generate the types+npx openapi-typescript http://api.browser-use.com/openapi.json -o browser-use-api.ts+```++This will create TypeScript definitions that you can use with your preferred HTTP client.++<Note>+ Need help? Contact our support team at [email protected] or join our+ [Discord community](https://link.browser-use.com/discord)+</Note>diff --git a/docs/mint.json b/docs/mint.jsonindex 0b928ae57..b0cbe467f 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -38,17 +38,14 @@"tabs": [{"name": "Cloud API",- "url": "/cloud-api",+ "url": "/cloud","openapi": "https://api.browser-use.com/openapi.json"}],"navigation": [{"group": "Get Started",- "pages": [- "introduction",- "quickstart"- ]+ "pages": ["introduction", "quickstart"]},{"group": "Customize",@@ -71,6 +68,10 @@"development/observability","development/roadmap"]+ },+ {+ "group": "Cloud API",+ "pages": ["cloud/quistart", "cloud/implementation"]}],"footerSocials": {@@ -78,4 +79,4 @@"github": "https://github.com/browser-use/browser-use","linkedin": "https://linkedin.com/company/browser-use"}-}\ No newline at end of file+}