Browser Automation
Extract content from web pages, capture screenshots, or execute complex browser tasks using AI — all through a single API with no account setup required.
Quick Example
Section titled “Quick Example”import { withSapiom } from "@sapiom/axios";import axios from "axios";
// Create a Sapiom-wrapped Axios clientconst client = withSapiom( axios.create({ baseURL: "https://anchor-browser.services.sapiom.ai" }), { apiKey: process.env.SAPIOM_API_KEY, baseURL: "https://api.sapiom.ai", serviceName: "Anchor Browser", agentName: "my-agent", });
// Extract webpage content - Sapiom tracks cost automaticallyconst { data } = await client.post("/v1/tools/fetch-webpage", { url: "https://example.com", format: "markdown",});
console.log("Page content:", data.content);import { createFetch } from "@sapiom/fetch";
// Create a Sapiom-tracked fetch functionconst sapiomFetch = createFetch({ apiKey: process.env.SAPIOM_API_KEY, baseURL: "https://api.sapiom.ai", serviceName: "Anchor Browser", agentName: "my-agent",});
// Extract webpage content - SDK handles payment/auth automaticallyconst response = await sapiomFetch( "https://anchor-browser.services.sapiom.ai/v1/tools/fetch-webpage", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ url: "https://example.com", format: "markdown", }), });
const data = await response.json();console.log("Page content:", data.content);How It Works
Section titled “How It Works”Sapiom routes browser automation requests to Anchor Browser, which provides AI-powered browser automation in the cloud. The SDK handles payment negotiation automatically — you pay based on the operation type and complexity.
The service supports three operations:
- Extract — Get page content as markdown or HTML
- Screenshot — Capture page screenshots at various sizes
- Task — Execute complex browser tasks with natural language instructions
Provider
Section titled “Provider”Powered by Anchor Browser. Anchor provides headless browser infrastructure with AI capabilities for intelligent web automation.
API Reference
Section titled “API Reference”Extract Content
Section titled “Extract Content”Endpoint: POST https://anchor-browser.services.sapiom.ai/v1/tools/fetch-webpage
Extract the main content from a webpage as clean markdown or HTML.
Request
Section titled “Request”| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to extract content from |
format | string | No | Output format: markdown or html (default: markdown) |
{ "url": "https://example.com/blog/article-title", "format": "markdown"}Response
Section titled “Response”{ "content": "# Article Title\n\nThis is the main content of the article...", "title": "Article Title", "url": "https://example.com/blog/article-title"}Capture Screenshot
Section titled “Capture Screenshot”Endpoint: POST https://anchor-browser.services.sapiom.ai/v1/screenshot
Capture a screenshot of a webpage.
Request
Section titled “Request”| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to screenshot |
fullPage | boolean | No | Capture entire scrollable page (default: false) |
format | string | No | Image format: png or jpeg (default: png) |
width | number | No | Viewport width in pixels, 320-3840 (default: 1280) |
height | number | No | Viewport height in pixels, 240-2160 (default: 720) |
quality | number | No | JPEG quality, 1-100 (default: 80) |
{ "url": "https://example.com", "fullPage": false, "format": "png", "width": 1280, "height": 720}Response
Section titled “Response”{ "image": "data:image/png;base64,iVBORw0KGgo...", "width": 1280, "height": 720}The image field contains the base64-encoded image data.
Execute AI Task
Section titled “Execute AI Task”Endpoint: POST https://anchor-browser.services.sapiom.ai/v1/task
Execute a complex browser task using natural language instructions. The AI agent navigates pages, fills forms, clicks buttons, and extracts data.
Request
Section titled “Request”| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Natural language task description |
url | string | No | Starting URL for the task |
maxSteps | number | No | Maximum AI steps, 1-50 (default: 10) |
{ "prompt": "Find the current price of Bitcoin on CoinMarketCap and return it", "url": "https://coinmarketcap.com", "maxSteps": 10}Response
Section titled “Response”{ "result": "The current price of Bitcoin is $67,432.15", "steps": [ { "action": "navigate", "description": "Navigated to coinmarketcap.com" }, { "action": "extract", "description": "Found Bitcoin price: $67,432.15" } ], "stepsUsed": 2}Price Estimation
Section titled “Price Estimation”Endpoints:
POST https://anchor-browser.services.sapiom.ai/v1/tools/fetch-webpage/pricePOST https://anchor-browser.services.sapiom.ai/v1/screenshot/pricePOST https://anchor-browser.services.sapiom.ai/v1/task/price
Get the estimated cost before making a request. Accepts the same parameters as the main endpoint.
{ "price": "$0.02", "currency": "USD"}Error Codes
Section titled “Error Codes”| Code | Description |
|---|---|
| 400 | Invalid request — check URL and parameters |
| 402 | Payment required — ensure you’re using the Sapiom SDK |
| 404 | Page not found or unreachable |
| 408 | Task timed out |
| 422 | Unable to complete task (blocked, CAPTCHA, etc.) |
| 429 | Rate limit exceeded |
Complete Example
Section titled “Complete Example”import { withSapiom } from "@sapiom/axios";import axios from "axios";
const client = withSapiom(axios.create(), { apiKey: process.env.SAPIOM_API_KEY,});
const baseUrl = "https://anchor-browser.services.sapiom.ai/v1";
async function scrapeArticle(url: string) { // Extract article content as markdown const { data } = await client.post(`${baseUrl}/extract`, { url, format: "markdown", });
return { title: data.title, content: data.content, };}
async function capturePagePreview(url: string) { // Capture a screenshot for social preview const { data } = await client.post(`${baseUrl}/screenshot`, { url, width: 1200, height: 630, format: "jpeg", quality: 90, });
// Convert base64 to buffer const imageBuffer = Buffer.from(data.image.split(",")[1], "base64"); return imageBuffer;}
async function researchCompetitor(companyUrl: string) { // Use AI to gather company information const { data } = await client.post(`${baseUrl}/task`, { prompt: `Visit the company website and extract: company name, main product/service, pricing information if available, and contact email`, url: companyUrl, maxSteps: 15, });
return data.result;}
// Usageconst article = await scrapeArticle("https://blog.example.com/post");console.log("Article:", article.title);
const preview = await capturePagePreview("https://example.com");console.log("Preview image size:", preview.byteLength, "bytes");
const research = await researchCompetitor("https://competitor.com");console.log("Research:", research);import { createFetch } from "@sapiom/fetch";
const fetch = createFetch({ apiKey: process.env.SAPIOM_API_KEY,});
const baseUrl = "https://anchor-browser.services.sapiom.ai/v1";
async function scrapeArticle(url: string) { // Extract article content as markdown const response = await fetch(`${baseUrl}/extract`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ url, format: "markdown", }), });
const data = await response.json(); return { title: data.title, content: data.content, };}
async function capturePagePreview(url: string) { // Capture a screenshot for social preview const response = await fetch(`${baseUrl}/screenshot`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ url, width: 1200, height: 630, format: "jpeg", quality: 90, }), });
const data = await response.json(); // Convert base64 to buffer const imageBuffer = Buffer.from(data.image.split(",")[1], "base64"); return imageBuffer;}
async function researchCompetitor(companyUrl: string) { // Use AI to gather company information const response = await fetch(`${baseUrl}/task`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ prompt: `Visit the company website and extract: company name, main product/service, pricing information if available, and contact email`, url: companyUrl, maxSteps: 15, }), });
const data = await response.json(); return data.result;}
// Usageconst article = await scrapeArticle("https://blog.example.com/post");console.log("Article:", article.title);
const preview = await capturePagePreview("https://example.com");console.log("Preview image size:", preview.byteLength, "bytes");
const research = await researchCompetitor("https://competitor.com");console.log("Research:", research);Pricing
Section titled “Pricing”| Operation | Price |
|---|---|
| Extract | $0.02 flat |
| Screenshot (viewport) | $0.02 |
| Screenshot (full page) | $0.03 |
| Task (base) | $0.05 |
| Task (per step) | $0.02 |
Task pricing formula: $0.05 + ($0.02 × maxSteps)
Example task costs:
- 10 steps (default): $0.25
- 20 steps: $0.45
- 50 steps: $1.05