← Templates Humanized REST template

Page-to-markdown extraction job

Turn a list of URLs into clean markdown records through the Humanized REST /v1/do/* layer.

Humanized RESTMarkdownExtraction

Use this when a workflow needs readable page content rather than screenshots or raw HTML. The template uses one session per job so cookies, navigation state, and egress stay consistent while you process the URL list.

Executable starters

extract-markdown.ts
const API_BASE = 'https://api.browser.city/v1';const apiKey = process.env.BROWSERCITY_API_KEY;if (!apiKey) {  throw new Error('Set BROWSERCITY_API_KEY before running this script.');}type OpenResponse = { sessionId: string };type MarkdownResponse = { result: string };async function callAction<T>(action: string, body: unknown): Promise<T> {  const response = await fetch(`${API_BASE}/do/${action}`, {    method: 'POST',    headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },    body: JSON.stringify(body),  });  if (!response.ok) {    throw new Error(`${action} failed: ${response.status} ${await response.text()}`);  }  return (await response.json()) as T;}const opened = await callAction<OpenResponse>('open', {  browser: 'chromium',  labels: ['template:page-to-markdown'],});try {  for (const url of ['https://example.com', 'https://example.org']) {    await callAction('navigate', { sessionId: opened.sessionId, url });    const page = await callAction<MarkdownResponse>('markdown', { sessionId: opened.sessionId });    console.log(JSON.stringify({ url, markdown: page.result }));  }} finally {  await callAction('close', { sessionId: opened.sessionId });}

Production hardening checklist

  • Persist each URL result as soon as it is extracted.
  • Retry failed URLs with your own queue policy rather than hiding errors.
  • Use labels to group jobs in BrowserCity usage views.
  • Keep secrets in environment variables or your secret manager, not in prompts.

Cost and plan notes

Start with a single worker and managed datacenter egress. If pages are large or you add residential/mobile egress requirements, update the traffic assumption in /pricing-calculator before scaling the batch size.

[ 06 / 06 ] — Get Started

Give your AI agents the web.

Start for free. No credit card required. Private sessions by default.