JavaScript teams often standardize on Puppeteer instead of Playwright. Multilogin still exposes a Chromium CDP endpoint — attach with puppeteer.connect, never launch raw Chrome when profile isolation matters.
Setup
npm init -y npm install puppeteer-core axios export MLX_TOKEN="your_token" export MLX_PROFILE_ID="profile_uuid"
Launch + attach + cleanup
const axios = require("axios");
const puppeteer = require("puppeteer-core");
const MLX = process.env.MLX_API || "https://api.multilogin.com";
const TOKEN = process.env.MLX_TOKEN;
const PROFILE = process.env.MLX_PROFILE_ID;
const headers = { Authorization: `Bearer ${TOKEN}` };
async function sleep(ms) {
return new Promise((r) => setTimeout(r, ms));
}
async function startProfile() {
for (let i = 0; i < 5; i++) {
try {
const { data, status } = await axios.post(
`${MLX}/profile/start`,
{ profile_id: PROFILE, headless: false },
{ headers, timeout: 90_000 }
);
if (status === 429) {
await sleep(2 ** i * 1000);
continue;
}
const cdp = data.cdp_url || data.wsUrl;
if (cdp) return cdp;
await sleep(2000);
} catch (e) {
await sleep(2 ** i * 1000);
}
}
throw new Error("CDP URL not available");
}
async function stopProfile() {
await axios.post(`${MLX}/profile/stop`, { profile_id: PROFILE }, { headers });
}
async function main() {
const cdpUrl = await startProfile();
const browser = await puppeteer.connect({ browserWSEndpoint: cdpUrl, defaultViewport: null });
try {
const pages = await browser.pages();
const page = pages[0] || (await browser.newPage());
await page.goto("https://example.com", { waitUntil: "domcontentloaded", timeout: 45_000 });
console.log(await page.title());
} finally {
browser.disconnect();
await stopProfile();
}
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
Node vs Python at scale
| Concern | Node.js | Python |
|---|---|---|
| Concurrency | p-limit or worker threads | asyncio.Semaphore — recipe |
| HTTP client | axios / undici | httpx |
| Browser attach | puppeteer-core connect | Playwright connect_over_cdp |
Related
Disclosure: MLX-MMO affiliated with Multilogin. Endpoint names vary — verify against official API docs.