# SDK

Part of the Oya Browser docs. All of it: https://oyabrowser.com/docs.md

## SDK

`@oya-ai/browser` is TypeScript with no runtime dependencies, shipped as ESM, CJS and types. Element IDs come from `analyze()` and are only valid until the page changes, after a navigation or a click that redraws, analyze again.

```
const page = await browser.analyze();      // markdown + numbered elements ({ format: 'toon' } for TOON)
const els  = await browser.elements();     // just the visible ones

await browser.click(13);
await browser.type(9, "hello");
await browser.pressKey("Enter");
await browser.waitFor("[data-testid=results]");
await browser.scroll("bottom");

const png = await browser.screenshot();    // base64
const answer = await browser.ask("find the pricing page");

await browser.solveCaptcha();              // { solved, method }
await browser.completeMfa();               // { completed, method, liveViewUrl }
await browser.close();
```

### Bring your own tools

`browser.cdpUrl` is our gateway URL, not the vendor's, point Playwright, Puppeteer, Stagehand or browser-use at it and you get routing, profile capture and session recording without any of them knowing this exists.

```
const browser = await oya.browser.start();
const pw = await chromium.connectOverCDP(browser.cdpUrl);
```

The gateway also answers `/json/version` and `/json/list`, which is what lets those clients treat it as an ordinary browser.
