Skip to content
Go To Dashboard

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.

import { withSapiom } from "@sapiom/axios";
import axios from "axios";
// Create a Sapiom-wrapped Axios client
const 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 automatically
const { data } = await client.post("/v1/tools/fetch-webpage", {
url: "https://example.com",
format: "markdown",
});
console.log("Page content:", data.content);

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:

  1. Extract — Get page content as markdown or HTML
  2. Screenshot — Capture page screenshots at various sizes
  3. Task — Execute complex browser tasks with natural language instructions

Powered by Anchor Browser. Anchor provides headless browser infrastructure with AI capabilities for intelligent web automation.

Endpoint: POST https://anchor-browser.services.sapiom.ai/v1/tools/fetch-webpage

Extract the main content from a webpage as clean markdown or HTML.

ParameterTypeRequiredDescription
urlstringYesURL to extract content from
formatstringNoOutput format: markdown or html (default: markdown)
{
"url": "https://example.com/blog/article-title",
"format": "markdown"
}
{
"content": "# Article Title\n\nThis is the main content of the article...",
"title": "Article Title",
"url": "https://example.com/blog/article-title"
}

Endpoint: POST https://anchor-browser.services.sapiom.ai/v1/screenshot

Capture a screenshot of a webpage.

ParameterTypeRequiredDescription
urlstringYesURL to screenshot
fullPagebooleanNoCapture entire scrollable page (default: false)
formatstringNoImage format: png or jpeg (default: png)
widthnumberNoViewport width in pixels, 320-3840 (default: 1280)
heightnumberNoViewport height in pixels, 240-2160 (default: 720)
qualitynumberNoJPEG quality, 1-100 (default: 80)
{
"url": "https://example.com",
"fullPage": false,
"format": "png",
"width": 1280,
"height": 720
}
{
"image": "data:image/png;base64,iVBORw0KGgo...",
"width": 1280,
"height": 720
}

The image field contains the base64-encoded image data.

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.

ParameterTypeRequiredDescription
promptstringYesNatural language task description
urlstringNoStarting URL for the task
maxStepsnumberNoMaximum AI steps, 1-50 (default: 10)
{
"prompt": "Find the current price of Bitcoin on CoinMarketCap and return it",
"url": "https://coinmarketcap.com",
"maxSteps": 10
}
{
"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
}

Endpoints:

  • POST https://anchor-browser.services.sapiom.ai/v1/tools/fetch-webpage/price
  • POST https://anchor-browser.services.sapiom.ai/v1/screenshot/price
  • POST 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"
}
CodeDescription
400Invalid request — check URL and parameters
402Payment required — ensure you’re using the Sapiom SDK
404Page not found or unreachable
408Task timed out
422Unable to complete task (blocked, CAPTCHA, etc.)
429Rate limit exceeded
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;
}
// Usage
const 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);
OperationPrice
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