A TypeScript client library for the Roxy Browser API that provides programmatic control over browser windows with advanced fingerprint management and proxy support.
- 🎭 Fingerprint Management - Create and manage browser fingerprints for privacy and automation
- 🌐 Proxy Support - Configure proxies for each browser window
- 🚀 Browser Automation - Full control over browser window lifecycle
- 📦 TypeScript First - Complete type definitions for all API operations
- 🔄 Multiple Formats - Supports both CommonJS and ES Modules
- ⚡ Modern Runtime - Built with Bun, works with Node.js
npm install roxy-browser-apior with your preferred package manager:
# Using pnpm
pnpm add roxy-browser-api
# Using yarn
yarn add roxy-browser-api
# Using bun
bun add roxy-browser-apiFirst, obtain your API token from the Roxy Browser dashboard.
Create a .env file in your project root:
ROXY_API_TOKEN=your_api_token_here
ROXY_API_BASE_URL=http://127.0.0.1:50000import { RoxyBrowserClient } from "roxy-browser-api";
async function main() {
// Initialize the client (automatically reads from environment variables)
const client = new RoxyBrowserClient();
// Get list of workspaces
const workspaceData = await client.getWorkspace({
page_index: 1,
page_size: 10,
});
console.log(`Found \${workspaceData.total} workspaces`);
// Create a new browser window
const browserWindow = await client.createBrowser({
workspaceId: workspaceData.rows[0].id,
windowName: "My Test Browser",
fingerInfo: {
language: "en-US",
timeZone: "America/New_York",
},
});
console.log(`Created browser window: \${browserWindow.windowId}`);
// Open the browser and get automation endpoints
const openResult = await client.openBrowser({
workspaceId: workspaceData.rows[0].id,
dirId: browserWindow.dirId,
});
console.log(`WebSocket endpoint: \${openResult.ws}`);
console.log(`HTTP endpoint: \${openResult.http}`);
}
main().catch(console.error);// Using environment variables
const client = new RoxyBrowserClient();
// Or provide credentials directly
const client = new RoxyBrowserClient("your_api_token", "http://127.0.0.1:50000");const workspaces = await client.getWorkspace({
page_index: 1,
page_size: 10,
});const browserWindow = await client.createBrowser({
workspaceId: 123,
windowName: "My Browser",
fingerInfo: {
language: "en-US",
timeZone: "America/New_York",
isLanguageBaseIp: false,
isTimeZone: false,
},
proxyInfo: {
// Optional proxy configuration
proxyType: "http",
proxyHost: "proxy.example.com",
proxyPort: 8080,
},
});const connection = await client.openBrowser({
workspaceId: 123,
dirId: "window_dir_id",
args: ["--remote-allow-origins=*"], // Optional browser launch arguments
});
// Use the WebSocket endpoint with Puppeteer or other automation tools
console.log(connection.ws); // WebSocket endpoint
console.log(connection.http); // HTTP endpoint
console.log(connection.driver); // ChromeDriver pathconst browsers = await client.getBrowserList({
workspaceId: 123,
page_index: 1,
page_size: 20,
});await client.updateBrowser({
workspaceId: 123,
dirId: "window_dir_id",
windowName: "Updated Name",
fingerInfo: {
language: "es-ES",
},
});await client.closeBrowser({
workspaceId: 123,
dirIds: ["window_dir_id_1", "window_dir_id_2"],
});await client.deleteBrowser({
workspaceId: 123,
dirIds: ["window_dir_id"],
});await client.randomizeFingerprint({
workspaceId: 123,
dirId: "window_dir_id",
});await client.clearLocalCache({
workspaceId: 123,
dirIds: ["window_dir_id"],
});await client.clearServerCache({
workspaceId: 123,
dirIds: ["window_dir_id"],
});const accounts = await client.getAccount({
workspaceId: 123,
page_index: 1,
page_size: 10,
});const labels = await client.getLabel({
workspaceId: 123,
});This library is written in TypeScript and provides complete type definitions for all API operations. All request and response types are exported for your convenience:
import type {
RoxyBrowserClient,
CreateBrowserRequest,
CreateBrowserResponse,
FingerInfo,
ProxyInfo,
// ... and many more
} from "roxy-browser-api";After opening a browser window, you can connect to it using Puppeteer:
import puppeteer from "puppeteer-core";
import { RoxyBrowserClient } from "roxy-browser-api";
const client = new RoxyBrowserClient();
// Create and open browser
const workspace = await client.getWorkspace();
const browser = await client.createBrowser({
workspaceId: workspace.rows[0].id,
windowName: "Puppeteer Test",
});
const connection = await client.openBrowser({
workspaceId: workspace.rows[0].id,
dirId: browser.dirId,
});
// Connect Puppeteer to the remote browser
const puppeteerBrowser = await puppeteer.connect({
browserWSEndpoint: connection.ws,
});
const page = await puppeteerBrowser.newPage();
await page.goto("https://example.com");
// Your automation code here...
await puppeteerBrowser.disconnect();The client throws errors for API failures. Always wrap your calls in try-catch blocks:
try {
const result = await client.createBrowser({
workspaceId: 123,
windowName: "Test",
});
} catch (error) {
if (error instanceof Error) {
console.error("API Error:", error.message);
}
}ROXY_API_TOKEN(required) - Your Roxy Browser API authentication tokenROXY_API_BASE_URL(optional) - API base URL (defaults tohttp://127.0.0.1:50000)
- Node.js 18+ or Bun 1.0+
- TypeScript 5.0+ (for TypeScript projects)
MIT
For API documentation and support, visit Roxy Browser Documentation.
Contributions are welcome! Please feel free to submit a Pull Request.