Skip to main content
Version: v2

BaaS Quick Start

Welcome to the Browser as a Service quick start! Here are some options for connecting your scripts or using our REST APIs for common tasks:

Bot Detection

BaaS features are best suited for sites where bot detection isn’t an issue, especially your own site. For getting past detectors, we’d recommend checking out BrowserQL.

Connecting Puppeteer

Libraries like puppeteer and chrome-remote-interface can hook into an existing Chrome instance by websocket. The hosted Browserless service only supports this type of interface since you can pass in tokens and other query-params. Typically you only need to replace how you start Chrome with a connect-like statement:

import puppeteer from "puppeteer-core";

// Connecting to Chrome locally
const browser = await puppeteer.launch();

// Connecting to Browserless and using a proxy
const browser = await puppeteer.connect({
browserWSEndpoint: `https://production-sfo.browserless.io/?token=${TOKEN}&proxy=residential`,
});

Refer to the Puppeteer Guide to learn more.

Connecting Playwright

We support all Playwright protocols, and, just like with Puppeteer, you can easily switch to Browserless. The standard connect method uses playwright's built-in browser-server to handle the connection. This, generally, is a faster and more fully-featured method since it supports most of the playwright parameters (such as using a proxy and more).

import playwright from "playwright";

// Connecting to Firefox locally
const browser = await playwright.firefox.launch();

// Connecting to Firefox via Browserless and using a proxy
const browser = await playwright.firefox.connect(`https://production-sfo.browserless.io/firefox/playwright?token=${TOKEN}&proxy=residential`);

Refer to the Playwright Guide to learn more.

/pdf API

The /pdf API allows you to navigate to any website and generate a PDF out of the page. This REST API exposes puppeteer's pdf options via an options property in the JSON body for granular control. Below you can see a basic usage example:

curl -X POST \
https://production-sfo.browserless.io/pdf?token=YOUR_API_TOKEN_HERE \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/",
"options": {
"displayHeaderFooter": true,
"printBackground": false,
"format": "A0"
}
}'

Refer to the /pdf API Guide for more details and usage examples.

/screenshot API

The /screenshot API exposes puppeteer's screenshot API through the posted JSON payload, allowing you to navigate to any website and taking a screenshot out of it. Below you can see a basic usage example:

curl -X POST \
https://production-sfo.browserless.io/screenshot?token=YOUR_API_TOKEN_HERE \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/",
"options": {
"fullPage": true,
"type": "png"
}
}' \
--output "screenshot.png"

Refer to the /screenshot API Guide for more details and usage examples.

What's Next?

BaaS provides a wide range of functionalities that help your web scraping process. To discover all the capabilities Browserless has to offer, start with the following guides:

Advanced Features

Learn about more advanced features that you can take advantage when using BaaS: