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 { createFetch } from "@sapiom/fetch";
// Create a Sapiom-tracked fetch function
const sapiomFetch = createFetch({
apiKey: process.env.SAPIOM_API_KEY,
agentName: "my-agent",
});
// Extract webpage content - SDK handles payment/auth automatically
const 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);

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 two operations:

  1. Extract — Get page content as markdown or HTML
  2. Screenshot — Capture page screenshots at various sizes

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)
waitnumberNoWait time in milliseconds for JavaScript execution
new_pagebooleanNoOpen URL in a new browser page (default: false)
page_indexnumberNoTarget page index in multi-page session
return_partial_on_timeoutbooleanNoReturn partial content if page times out (default: false)
{
"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/tools/screenshot

Capture a screenshot of a webpage.

ParameterTypeRequiredDescription
urlstringYesURL to screenshot
widthnumberNoViewport width in pixels, 320-3840 (default: 1280)
heightnumberNoViewport height in pixels, 240-2160 (default: 720)
image_qualitynumberNoJPEG quality, 1-100 (default: 80)
waitnumberNoWait time in milliseconds for JavaScript execution
scroll_all_contentbooleanNoScroll through page to capture all content (default: false)
capture_full_heightbooleanNoCapture full page height, not just viewport (default: false)
formatstringNoImage format: png or jpeg (default: png)
s3_target_addressstringNoS3 URL for direct upload instead of returning image
fullPagebooleanNoDeprecated — use capture_full_height + scroll_all_content instead
qualitynumberNoDeprecated — use image_quality instead
{
"url": "https://example.com",
"capture_full_height": false,
"format": "png",
"width": 1280,
"height": 720
}

The response is binary image data with the appropriate Content-Type header (image/png or image/jpeg). Use responseType: "arraybuffer" (Axios) or response.arrayBuffer() (Fetch) to handle the binary response.

Endpoints:

  • POST https://anchor-browser.services.sapiom.ai/v1/tools/fetch-webpage/price
  • POST https://anchor-browser.services.sapiom.ai/v1/tools/screenshot/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
429Rate limit exceeded
import { createFetch } from "@sapiom/fetch";
const sapiomFetch = createFetch({
apiKey: process.env.SAPIOM_API_KEY,
agentName: "my-agent",
});
const baseUrl = "https://anchor-browser.services.sapiom.ai/v1";
async function scrapeArticle(url: string) {
// Extract article content as markdown
const response = await sapiomFetch(`${baseUrl}/tools/fetch-webpage`, {
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 sapiomFetch(`${baseUrl}/tools/screenshot`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
url,
width: 1200,
height: 630,
format: "jpeg",
image_quality: 90,
}),
});
return Buffer.from(await response.arrayBuffer());
}
// 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");
OperationPrice
Extract$0.01 flat
Screenshot$0.01 flat