Skip to main content

Requirements

  • Node.js 18 or higher
  • npm, pnpm, or yarn

Install the SDK

npm install @bctrl/sdk

Configuration

Environment Variables

Set your API key as an environment variable:
export BCTRL_API_KEY=your_api_key_here
Or create a .env file:
.env
BCTRL_API_KEY=your_api_key_here

TypeScript Configuration

The SDK is written in TypeScript and includes type definitions. No additional @types packages needed.
tsconfig.json
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "esModuleInterop": true,
    "strict": true
  }
}

SDK Exports

import {
  // Drivers
  playwright,    // Playwright driver
  puppeteer,     // Puppeteer driver
  selenium,      // Selenium driver
  stagehand,     // Stagehand driver

  // Client
  BCTRLClient,

  // Types
  type SessionOptions,
  type DriverType
} from '@bctrl/sdk';

Connection Options

All drivers accept these common options:
const session = await playwright.connect({
  // Required
  apiKey: string,

  // Optional
  baseUrl: string,              // Default: https://api.bctrl.ai
  sessionOptions: {
    driver: 'playwright',       // Driver type
    humanize: boolean,          // Human-like mouse movement
    useStealth: boolean,        // Anti-detection features
    useProxy: boolean,          // Use proxy
    proxyCountry: string,       // Proxy location
    screen: {
      width: number,
      height: number
    },
    timeoutMinutes: number      // Session timeout
  }
});

Verify Installation

import { playwright } from '@bctrl/sdk';

async function verify() {
  try {
    const session = await playwright.connect({
      apiKey: process.env.BCTRL_API_KEY!
    });

    console.log('Connected! Session ID:', session.id);
    await session.close();
    console.log('Installation verified.');
  } catch (error) {
    console.error('Connection failed:', error);
  }
}

verify();
If you see “Installation verified”, you’re ready to go!