BTW: Browse The Web - AI Browser Automation API with Dual Browser Control Systems
An AI-powered browser automation API that gives AI agents, applications, and developers full control over browsers through simple HTTP endpoints.
β
System 1: Playwright Controlled (/api/browser, /api/tabs) - Headless browser automation
β
System 2: Chrome Extension Controlled (/api/browser/:sessionId/tabs/*) - Real browser control
Perfect for web scraping, automated testing, RPA, and AI-driven workflows.
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm start
# Server runs on http://localhost:5409# Launch browser
curl -X POST http://localhost:5409/api/browser/launch
# Create tab
curl -X POST http://localhost:5409/api/tabs/create
# Navigate to a website
curl -X POST http://localhost:5409/api/tabs/{sessionId}/goto \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com"}'
# Extract data
curl -X POST http://localhost:5409/api/tabs/{sessionId}/evaluate \
-H "Content-Type: application/json" \
-d '{"script":"document.title"}'
# Close browser
curl -X POST http://localhost:5409/api/browser/closeStep 1: Install the Extension
# Build the extension
npm run dev
# Load in Chrome:
# 1. Navigate to chrome://extensions
# 2. Enable "Developer mode" (top-right toggle)
# 3. Click "Load unpacked"
# 4. Select: dist/btw-chrome-extension/Step 2: Use the Extension API
# Get connected session ID
curl http://localhost:5409/api/websocket/sessions
# Create tab in real browser
curl -X POST http://localhost:5409/api/browser/{sessionId}/tabs/create \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com"}'
# Click element
curl -X POST http://localhost:5409/api/browser/{sessionId}/tabs/{tabId}/click \
-H "Content-Type: application/json" \
-d '{"selector":"#button"}'
# Take screenshot
curl -X POST http://localhost:5409/api/browser/{sessionId}/tabs/captureNote: See EXTENSION_INSTALLATION.md for detailed setup instructions or CHROME_EXTENSION_API.md for the complete API reference.
-
π Playwright System: Headless browser automation with complete programmatic control
- No browser installation needed
- Full access to all browser APIs
- Perfect for scraping and testing
- Docs:
API_BLUEPRINT.md
-
π Chrome Extension System: Control real Chrome browser via WebSocket
- Real browser context with all extensions
- User's cookies and authentication preserved
- Ideal for human-in-the-loop workflows
- Docs:
CHROME_EXTENSION_API.md
- π§ AI-Ready: Perfect for AI agents and LLMs to control browsers programmatically
- π― 100+ Endpoints: Full browser automation across both systems
- π Web Scraping: Extract text, images, forms, and structured data from any website
- π Network Monitoring: Intercept, mock, and analyze network traffic for debugging
- πΌοΈ Screenshots & PDF: Capture full-page screenshots and export pages as PDF
- π Multi-Tab Management: Handle multiple isolated browser contexts simultaneously
- β‘ Fast & Reliable: Built on Playwright Chromium engine for speed and stability
- π REST API: Simple HTTP endpoints with JSON responses - easy to integrate
- π‘οΈ Isolated Contexts: Each tab runs in isolated browser context (separate cookies, storage)
- π TypeScript: Fully typed codebase with excellent IDE support and type safety
- π Serverless Debugging: All errors and debugging info in HTTP responses - no server logs needed!
- Control Browsers: Give AI models eyes and hands to interact with websites dynamically
- Render JavaScript: Access content from SPAs and JavaScript-heavy applications
- Web Research: Analyze website structure, design patterns, and functionality
- Data Extraction: Scrape data dynamically for research and content generation
- Web Scraping: Extract data from websites that block simple HTTP requests or require JavaScript
- Automated Testing: Write end-to-end tests for web applications with real browser execution
- RPA (Robotic Process Automation): Automate repetitive browser tasks and workflows
- Screenshot Generation: Generate PDFs and screenshots for documentation and reports
- Network Debugging: Monitor and analyze API calls, headers, and responses from frontend applications
- Product Data Collection: Scrape product catalogs from e-commerce platforms
- Social Media Monitoring: Track social media posts, trends, and engagement
- Price Tracking: Monitor pricing across multiple websites and marketplaces
- Lead Generation: Extract contact information from business directories
- Competitor Analysis: Analyze competitor pricing, features, and content
- QUICK_REFERENCE.md - Start here! Quick cheat sheet for AI models with common operations and endpoints
- CHROME_EXTENSION_API.md - Complete guide for Chrome Extension WebSocket API system
- EXTENSION_INSTALLATION.md - Detailed Chrome extension installation and troubleshooting guide
- API_BLUEPRINT.md - Complete technical API reference for Playwright system (80+ endpoints)
- DEBUGGING_GUIDE.md - Comprehensive debugging guide - NO server logs needed! All errors in responses
| System | Base URL | Use Case | Docs |
|---|---|---|---|
| Playwright | /api/browser, /api/tabs |
Headless automation, scraping, testing | API_BLUEPRINT.md |
| Chrome Extension | /api/browser/:sessionId/tabs/* |
Real browser control, human workflows | CHROME_EXTENSION_API.md |
-
Use Playwright System when:
- You need headless mode
- You don't want to install Chrome
- You're scraping many pages
- You need full programmatic control
-
Use Chrome Extension System when:
- You need real browser extensions
- You need user's authentication/cookies
- You're doing human-in-the-loop workflows
- You need to debug in real browser
btw/
βββ Documentation/
β βββ API_BLUEPRINT.md # Playwright system API (80+ endpoints)
β βββ CHROME_EXTENSION_API.md # Chrome Extension WebSocket API
β βββ DEBUGGING_GUIDE.md # Debugging without server logs
β βββ QUICK_REFERENCE.md # Quick cheat sheet for AI agents
βββ Extension/
β βββ dist/btw-chrome-extension/ # Chrome extension (auto-connected)
βββ app.js # Main server entry point
βββ package.json # Dependencies
βββ README.md # This file
βββ controllers/ # Request handlers
β βββ browserController.js
β βββ tabsController.js
βββ managers/ # Business logic
β βββ BrowserManager.js # Browser lifecycle
β βββ TabManager.js # Tab management
β βββ index.js
βββ routes/ # API routes
βββ browser.js
βββ tabs.js
- Node.js: 18.0 or higher
- npm: 9.0 or higher
- OS: Windows, macOS, or Linux (Playwright supports all major platforms)
# Clone the repository
git clone https://github.com/ASAYMAN69/btw.git
cd btw
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm startnpm install -g browse-the-web
btw start| Feature | BTW | Puppeteer | Selenium |
|---|---|---|---|
| API Type | REST/HTTP | JavaScript SDK | Multiple language bindings |
| AI Integration | β Native support | β Requires wrapper | β Complex setup |
| Browser Engine | Playwright (Chromium) | Chromium | Multiple browsers |
| Multi-Tab Management | β Isolated contexts | β | |
| Network Interception | β Built-in | β Manual | |
| Screenshots/PDF | β Native | β Native | |
| TypeScript Support | β Fully typed | ||
| Learning Curve | β€οΈ Simple (REST API) | ||
| Memory Usage | β‘ Optimized | β‘ Optimized |
BTW stands out for:
- Simple REST API: No SDK required - just HTTP requests
- AI-Friendly: Designed specifically for AI agents and LLM integration
- Isolated Contexts: Each tab has separate cookies and storage
- Type Safety: Fully written in TypeScript with comprehensive types
- Active Development: Built with modern best practices
# Build the project
npm run build
# Start server
npm start
# API health check
curl http://localhost:5409/api/health- Launch, close, restart browser
- Check browser status
- Create, close, switch tabs
- List all tabs
- Go to URL, back, forward, reload
- Click, type, fill, hover, scroll
- Double-click, right-click, tap
- Execute JavaScript
- Get page content
- Screenshots and PDFs
- Intercept requests
- Mock responses
- Monitor traffic
- Manage cookies
- Access localStorage/sessionStorage
- Fill and submit forms
- Upload files
- Set viewport
- Emulate geolocation
- Set user agent
- Run in headless mode for production
- Use appropriate rate limiting
- Sanitize user inputs
- Manage browser contexts securely
MIT
Contributions welcome! Please read the documentation and ensure all endpoints are tested.
For issues and questions, please refer to the API_BLUEPRINT.md documentation.
Keywords: browser automation, web scraping, headless browser, Chrome automation, Playwright, TypeScript, REST API, HTTP API, AI agent, LLM integration, automated testing, RPA, web crawler, puppeteer alternative, selenium alternative, browser control, screenshot API, PDF generation, network monitoring.
Tags: #browser-automation #web-scraping #headless-browser #playwright #typescript #rest-api #ai-agent #llm #testing #rpa #web-crawler
- Playwright - Browser automation library that powers BTW
- Puppeteer - Node.js library for controlling Chrome
- Selenium - Browser automation framework
- Cypress - End-to-end testing framework
- Docker container support
- WebSocket API for real-time updates
- Video recording capability
- Mobile browser emulation (iOS/Android)
- Cluster mode for multiple browser instances
- Rate limiting and authentication
- Swagger/OpenAPI documentation
- Startup Time: ~2-3 seconds (browser launch)
- Memory per Tab: ~50-100MB (Chrome headless)
- Request Latency: ~10-50ms (local API calls)
- Concurrent Tabs: 10+ (depends on hardware)
Star us on GitHub if you find BTW useful!
Share your use cases with #BrowseTheWeb
Browse The Web (BTW) - Making browser automation easy for AI agents and developers. Built with β€οΈ using TypeScript, Express, and Playwright.