SDKs
Small libraries for Node.js, Python, Java, C# and Go that wrap the cdpfleet API: launch a browser (retrying when the fleet is busy, as the API asks), connect your own Playwright to it, and close it — plus keep_alive reconnects, live links, proxy swaps, recordings and your usage. You don't need them: every example on this site also works with plain Playwright and one HTTP call. They just remove the boilerplate.
// npm install cdpfleet [email protected]
// Browsers run on cdpfleet, so no `npx playwright install` is needed.
import { chromium } from 'playwright';
import { Cdpfleet } from 'cdpfleet';
const fleet = new Cdpfleet(); // reads CDPFLEET_API_KEY
const options = {
proxy: 'http://user:[email protected]:8080',
headless: 'new',
};
const session = await fleet.launch('chromium', options);
const browser = await session.connect(chromium);
const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.title());
await session.close(); // ends the session and stops billing
# pip install cdpfleet playwright==1.60.0
# Browsers run on cdpfleet, so no `playwright install` is needed.
from cdpfleet import Cdpfleet
from playwright.sync_api import sync_playwright
fleet = Cdpfleet() # reads CDPFLEET_API_KEY
options = {
"proxy": "http://user:[email protected]:8080",
"headless": "new",
}
with sync_playwright() as p, fleet.launch("chromium", options) as session:
browser = session.connect(p.chromium)
page = browser.new_page()
page.goto("https://example.com")
print(page.title())
# leaving the block closes the session and stops billing
// The cdpfleet SDK for Java (Maven Central) isn't published yet, so this is the plain
// Playwright version — it works today. The SDK will remove the launch boilerplate.
// Maven: com.microsoft.playwright:playwright:1.60.0 and com.google.code.gson:gson:2.11.0
// Run with PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1: browsers run on cdpfleet.
import com.google.gson.JsonParser;
import com.microsoft.playwright.*;
import java.net.URI;
import java.net.http.*;
import java.util.Map;
public class Example {
public static void main(String[] args) throws Exception {
String key = System.getenv("CDPFLEET_API_KEY");
// 1. Launch the browser
String body = """
{
"proxy": "http://user:[email protected]:8080",
"headless": "new"
}
""";
HttpResponse<String> res = HttpClient.newHttpClient().send(
HttpRequest.newBuilder(URI.create("https://starter.cdpfleet.com/chromium/session"))
.header("x-api-key", key)
.header("content-type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build(),
HttpResponse.BodyHandlers.ofString());
if (res.statusCode() != 200) {
throw new RuntimeException("launch failed: " + res.statusCode() + " " + res.body());
}
String wsUrl = JsonParser.parseString(res.body()).getAsJsonObject().get("wsUrl").getAsString();
// 2. Connect and drive it
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().connect(wsUrl,
new BrowserType.ConnectOptions().setHeaders(Map.of("x-api-key", key)));
Page page = browser.newPage();
page.navigate("https://example.com");
System.out.println(page.title());
browser.close(); // ends the session and stops billing
}
}
}
// The cdpfleet SDK for C# (NuGet) isn't published yet, so this is the plain
// Playwright version — it works today. The SDK will remove the launch boilerplate.
// dotnet add package Microsoft.Playwright --version 1.60.0
// Browsers run on cdpfleet, so no `playwright install` is needed.
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using Microsoft.Playwright;
var key = Environment.GetEnvironmentVariable("CDPFLEET_API_KEY")!;
// 1. Launch the browser
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("x-api-key", key);
var body = """
{
"proxy": "http://user:[email protected]:8080",
"headless": "new"
}
""";
var res = await http.PostAsync("https://starter.cdpfleet.com/chromium/session",
new StringContent(body, Encoding.UTF8, "application/json"));
if (!res.IsSuccessStatusCode)
throw new Exception($"launch failed: {(int)res.StatusCode} {await res.Content.ReadAsStringAsync()}");
var wsUrl = (await res.Content.ReadFromJsonAsync<JsonElement>()).GetProperty("wsUrl").GetString()!;
// 2. Connect and drive it
using var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.ConnectAsync(wsUrl, new BrowserTypeConnectOptions
{
Headers = new Dictionary<string, string> { ["x-api-key"] = key },
});
var page = await browser.NewPageAsync();
await page.GotoAsync("https://example.com");
Console.WriteLine(await page.TitleAsync());
await browser.CloseAsync(); // ends the session and stops billing
// go get github.com/cdpfleet/cdpfleet/sdk/go github.com/playwright-community/[email protected]
//
// One-time driver setup (needs Node.js 18+): playwright-go can no longer download the
// 1.60.0 driver itself, so build it from npm and point PLAYWRIGHT_DRIVER_PATH at it:
// mkdir -p ~/.cache/pw-driver-1.60.0 && cd ~/.cache/pw-driver-1.60.0 &&
// curl -sL https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0.tgz | tar xz &&
// ln -sf "$(command -v node)" node
// export PLAYWRIGHT_DRIVER_PATH=~/.cache/pw-driver-1.60.0
package main
import (
"encoding/json"
"fmt"
"log"
cdpfleet "github.com/cdpfleet/cdpfleet/sdk/go"
"github.com/playwright-community/playwright-go"
)
func main() {
fleet, err := cdpfleet.New() // reads CDPFLEET_API_KEY
if err != nil {
log.Fatal(err)
}
var options cdpfleet.Options
if err := json.Unmarshal([]byte(`{
"proxy": "http://user:[email protected]:8080",
"headless": "new"
}`), &options); err != nil {
log.Fatal(err)
}
pw, err := playwright.Run(&playwright.RunOptions{SkipInstallBrowsers: true})
if err != nil {
log.Fatal(err)
}
defer pw.Stop()
session, err := fleet.Launch("chromium", options)
if err != nil {
log.Fatal(err)
}
defer session.Close() // ends the session and stops billing
browser, err := session.Connect(pw.Chromium)
if err != nil {
log.Fatal(err)
}
page, err := browser.NewPage()
if err != nil {
log.Fatal(err)
}
if _, err := page.Goto("https://example.com"); err != nil {
log.Fatal(err)
}
title, _ := page.Title()
fmt.Println(title)
}
The code builder writes this for any browser and options — switch it between SDK and Plain.
Install
Node.js, Python and Go are published (0.1.1). The C# and Java packages are on their way to NuGet and Maven Central — until then they build from their source on GitHub.
| Language | Package | Playwright (yours) |
|---|---|---|
| Node.js | npm install cdpfleet (ESM, TypeScript types) | [email protected] |
| Python | pip install cdpfleet (sync and async) | playwright==1.60.0 |
| Java | Maven com.cdpfleet:cdpfleet:0.1.0 (coming soon) | com.microsoft.playwright:playwright:1.60.0 |
| C# | dotnet add package Cdpfleet (coming soon) | Microsoft.Playwright 1.60.0 |
| Go | go get github.com/cdpfleet/cdpfleet/sdk/go | playwright-go v0.6000.0 |
The SDKs never bundle Playwright: you pass your own browser type (chromium, firefox, webkit), so you choose the client version — 1.60 for every browser, 1.52 for Rebrowser. Sources, specification and examples: github.com/cdpfleet/cdpfleet/sdk.
What they do for you
- Launch with the right retries:
503(fleet busy) and429(rate or thread limit) are retried, honouringRetry-After, for up to two minutes; quota errors and bad requests fail at once with the API's error code. - Connect, or connect over CDP:
session.connect(chromium)orsession.connectOverCDP(chromium)(launch withcdp: true) — the key goes in the header. - One-step connect URL:
fleet.connectUrl('chrome', { headless: 'new' })(Pythonconnect_url, GoConnectURL) returns a launch-on-connect URL —chromium.connect(url, { headers: fleet.headers() })launches and connects in one step, and the URL drops straight into Playwright Test'swsEndpoint.cdp: truegives a/cdpURL forconnectOverCDPor Puppeteer. Node.js, Python and Go for now. - keep_alive: call
connectagain after a disconnect to re-attach (the SDK waits out the few seconds the router needs);close()ends a keep_alive session, whichbrowser.close()alone doesn't. - Live view and proxy swap:
session.liveLink('control')returns a live link;session.swapProxy(proxy, rules)moves aproxy_updatablesession to another proxy. - Account API: usage, live threads, session history, recordings (list, link, delete) and your residential balance.
Names in each language
| Node.js | Python | Java | C# | Go | |
|---|---|---|---|---|---|
| Client | new Cdpfleet() | Cdpfleet() / AsyncCdpfleet() | new Cdpfleet() | new CdpfleetClient() | cdpfleet.New() |
| Launch | await fleet.launch(name, options) | fleet.launch(name, options) | fleet.launch(name, Map) | await fleet.LaunchAsync(name, options) | fleet.Launch(name, cdpfleet.Options{…}) |
| Connect URL | fleet.connectUrl(name, options) | fleet.connect_url(name, options) | — | — | fleet.ConnectURL(name, cdpfleet.Options{…}) |
| Done | await session.close() | with … as session: | try-with-resources | await using var session | defer session.Close() |
The API key comes from CDPFLEET_API_KEY unless you pass one. For AI agents, see the MCP server.