Skip to main content
POST /v1/browser/{session_id}/execute runs code or a prompt in a session you opened, and answers with what it printed and returned. Run as many calls as you need on one session, then close it.

Run code

Open a session first. In your code, page is the session’s page, with Playwright-style methods. Every page call is asynchronous, so await it. This call opens a page, then returns its title and address.
result is the value your code returned, as text. output is what it printed.
The call costs nothing. A failed run still answers 200, so check exitCode and error before you trust result.

Choose a language

Send language as node (the default), python or bash. Each reads the same page. This Python run returned exitCode 0 and the same result as the Node run above.

Run a prompt

Send prompt instead of code to say what you want in plain words. Stophy clicks and types on the page for you, up to 50 steps, and answers in words.
This real run took about 13 seconds. The links are cut.
result and output hold the answer. steps lists what was done, and page is where the session ended up. When the prompt could not be finished, exitCode is 1 and stderr says why.

Options

Send code or prompt. A body with neither returns 400 invalidRequest with Send code or a prompt.

Read the response

Price

A call costs nothing. What changes is the session’s price: a session is $0.06 per hour open, and once a prompt has run it is $0.84 per hour for its whole time. Code never raises the price. Traffic is billed as usual, per GB. A session that opened, ran one prompt and closed after 27 seconds cost $0.022: one minute of browser time at the prompt price, $0.014, and $0.008 for 1.3 MB of traffic. See Browser sessions.

Limits and errors

  • The first call right after a session opens can fail with 503 internalError and the message We couldn't complete your request. Try again shortly. It is retryable: send it again.
  • Code that runs past timeout returns killed: true and error The code ran out of time.
  • A session that has ended returns 410 notFound with This browser session has ended.
  • url and zeroDataRetention are not accepted on this call. Open the page with page.goto in your code, and set zero data retention when you open the session.
  • Browser sessions opens and closes the session this call runs in.
  • Files puts a file in the session for a file field to use.
  • Tasks runs a goal on a public site without a session of your own.
  • Browser actions run steps on a page during one scrape.