On this page

Recipes

These examples use Node.js 20+, npm install @roveapi/[email protected], and ROVE_API_KEY exported to a live key with credits. Run them as ES modules or TypeScript. For equivalent Python lifecycle code, see SDKs. Use only sites and accounts you are authorized to operate.

Login and handoff

Input: set LOGIN_URL to your site's sign-in page. The agent parks for a person, prints the one-time viewer link, waits at most five minutes, and re-reads the page once control is returned. The person signs in inside the viewer, then selects Return to agent. Do not send passwords through chat.

typescript
import { BrowserClient } from '@roveapi/browser'

const rove = new BrowserClient({ apiKey: process.env.ROVE_API_KEY!, retries: 0 })
const session = await rove.session({ supervised: true })
try {
  await session.navigate(process.env.LOGIN_URL!)
  const handoff = await session.requestHuman('Please sign in, then return control to the agent')
  console.log('Open once:', handoff.result.viewer_url)
  const deadline = Math.min(Date.now() + 5 * 60_000, Date.parse(handoff.result.human_wait_expires_at))
  let returned = false
  while (Date.now() < deadline) {
    await new Promise((resolve) => setTimeout(resolve, 5000))
    const state = await rove.getSession(session.id)
    if (state.status === 'closed') throw new Error('Session ended during handoff')
    if (state.status === 'active' && 'controller' in state && state.controller === 'agent') { returned = true; break }
  }
  if (!returned) throw new Error('Human handoff timed out')
  console.log((await session.getA11yTree()).result.tree)
} finally {
  await session.close()
}

Expected observation: an authenticated page in the returned tree. Verify a site-specific signed-in marker before continuing. If the viewer grant expires, mint one fresh grant; if handoff times out, stop and close rather than polling forever. For missing control, follow stale-control recovery. Relevant actions: navigate, request_human and get_a11y_tree.

Form filling

Input: set FORM_URL to a form you control with an accessible field labeled Email, and FORM_EMAIL to a test value. The example fills the field and reads it back without submitting.

typescript
import { BrowserClient } from '@roveapi/browser'

const rove = new BrowserClient({ apiKey: process.env.ROVE_API_KEY!, retries: 0 })
const session = await rove.session({ supervised: true })
try {
  await session.navigate(process.env.FORM_URL!)
  console.log((await session.getA11yTree()).result.tree)
  await session.fill({ label: 'Email', value: process.env.FORM_EMAIL! })
  console.log((await session.getAttribute('input[type="email"]', 'value')).result)
} finally {
  await session.close()
}

Expected observation: result.value matches the supplied email on a form whose input reflects the value attribute. If the site only changes the DOM property, inspect with a fresh tree or screenshot instead. Adjust the label and selector to your form. If no field matches, inspect the current page and frame before retrying once; stop if it is still missing. Any submission or purchase needs a separate review of the filled form and owner authorization. Relevant actions: fill, get_attribute and page/frame targeting.

Structured extraction

Input: set EXTRACT_URL to a public page you control containing labeled text such as Price: $10. The schema maps result keys to descriptions; this extractor reads the text following each key, rather than performing arbitrary AI inference. Missing labels return null.

typescript
import { BrowserClient } from '@roveapi/browser'

const rove = new BrowserClient({ apiKey: process.env.ROVE_API_KEY!, retries: 0 })
const result = await rove.extract({
  url: process.env.EXTRACT_URL!,
  schema: { Price: 'Displayed price including currency' },
})
console.log(result.data)

Expected observation: { "Price": "$10" } for that input. A null value means the label was not found; inspect the source text and adjust the key once, then report missing data. One-shot extraction uses a throwaway browser with automatic cleanup and no supervised viewer. For signed-in data, use the supervised session from the first recipe, read get_text or get_a11y_tree, structure the result in your application, and close in finally. See extract endpoint and reading pages.

Help improve this page: Report a correction.

Blocked on a task? Contact support. Include the error type and session ID; omit keys and viewer credentials.

Rove — the supervised browser for agents