Using your API token
info
Currently, Browserless V2 is available in production via two domains: production-sfo.browserless.io
and production-lon.browserless.io
When you sign-up for a Browserless account, we create a unique token that allows you to interact with the service. Once your worker(s) are ready you should use this token anytime you interact with the service.
You can use this token with most of our integrations by simply appending a ?token=YOUR_API_TOKEN_HERE
as a query-string parameter.
For the purposes of illustrating these examples, we'll assume your API-TOKEN is 094632bb-e326-4c63-b953-82b55700b14c
.
Puppeteer with your API Token
const browser = puppeteer.connect({
browserWSEndpoint: 'wss://production-sfo.browserless.io?token=094632bb-e326-4c63-b953-82b55700b14c',
});
Playwright with your API Token
- Javascript
- Python
- Java
- C#
import playwright from "playwright";
const browser = await playwright.firefox.connect(
`wss://production-sfo.browserless.io/chromium/playwright?token=094632bb-e326-4c63-b953-82b55700b14c`
);
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.firefox.connect_over_cdp("wss://production-sfo.browserless.io/firefox/playwright?token=094632bb-e326-4c63-b953-82b55700b14c")
import com.microsoft.playwright.*;
public class PlaywrightRemoteFirefox {
public static void main(String[] args) {
String browserWsEndpoint = "wss://production-sfo.browserless.io/chromium/playwright?token=094632bb-e326-4c63-b953-82b55700b14c";
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.firefox().connect(browserWsEndpoint);
}
}
}
using System;
using System.Threading.Tasks;
using Microsoft.Playwright;
class Program {
static async Task Main(string[] args) {
string browserWsEndpoint = "wss://production-sfo.browserless.io/chromium/playwright?token=094632bb-e326-4c63-b953-82b55700b14c";
var playwright = await Playwright.CreateAsync();
var browser = await playwright.Firefox.ConnectAsync(browserWsEndpoint);
}
}
REST with your API Token
The basic way to send your API token over HTTP, is to simply add it as a query parameter:
curl -X POST \
https://production-sfo.browserless.io/content?token=094632bb-e326-4c63-b953-82b55700b14c \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{ "url": "https://example.com/" }'