@oya-ai/browser 1.0.56 → 1.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Thousands of browsers behind one API: personas, proxies, stealth, CAPTCHA and MF
|
|
|
6
6
|
npm i @oya-ai/browser
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Get an API key at [browser.getoya.ai](https://browser.getoya.ai) and export it as `OYA_API_KEY`.
|
|
9
|
+
Get an API key at [browser.getoya.ai](https://browser.getoya.ai) and export it as `OYA_API_KEY`. Every snippet below runs as-is.
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
@@ -19,41 +19,74 @@ await browser.goto('https://news.ycombinator.com');
|
|
|
19
19
|
console.log(await browser.ask('What are the top 3 stories?'));
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
`await using` needs Node 24+ or TypeScript 5.2+. Otherwise call `await browser.stop()` in a `finally` block.
|
|
22
|
+
`await using` needs Node 24+ or TypeScript 5.2+. Otherwise call `await browser.stop()` in a `finally` block. `ask()` uses the AI model set on your key in the dashboard.
|
|
23
23
|
|
|
24
24
|
## Personas
|
|
25
25
|
|
|
26
26
|
A persona is one device: fingerprint, cookie jar and exit IP, the same on every run.
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
+
import { Oya } from '@oya-ai/browser';
|
|
30
|
+
|
|
31
|
+
const oya = new Oya();
|
|
29
32
|
const persona = await oya.personas.create({
|
|
30
33
|
name: 'us-shopper',
|
|
31
34
|
prefs: { platform: 'MacIntel', timezone: 'America/New_York', locale: 'en-US' }, // fixed for life
|
|
32
35
|
proxy: { geo: 'US' },
|
|
33
36
|
});
|
|
34
|
-
await using browser = await oya.browser.start({ persona: persona.id }); // or 'auto' to rotate
|
|
37
|
+
await using browser = await oya.browser.start({ persona: persona.id }); // or persona: 'auto' to rotate
|
|
38
|
+
await browser.goto('https://example.com');
|
|
39
|
+
console.log(persona.fingerprint.platform, persona.fingerprint.timezone); // the same on every run
|
|
35
40
|
```
|
|
36
41
|
|
|
37
|
-
## CAPTCHA
|
|
42
|
+
## CAPTCHA
|
|
43
|
+
|
|
44
|
+
The vendor's own solver when it has one, otherwise your CapSolver or 2Captcha key.
|
|
38
45
|
|
|
39
46
|
```ts
|
|
40
|
-
|
|
41
|
-
await browser.solveCaptcha(); // or on demand
|
|
47
|
+
import { Oya } from '@oya-ai/browser';
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
const oya = new Oya();
|
|
50
|
+
await using browser = await oya.browser.start(); // or start({ captcha: 'auto' }) to clear them on every goto()
|
|
51
|
+
await browser.goto('https://www.google.com/recaptcha/api2/demo');
|
|
52
|
+
console.log(await browser.solveCaptcha()); // { present, solved, method: 'provider' | 'solver' | 'none' }
|
|
46
53
|
```
|
|
47
54
|
|
|
48
|
-
##
|
|
55
|
+
## MFA
|
|
56
|
+
|
|
57
|
+
The TOTP seed is sealed on the persona, and `completeMfa()` enters the code.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { Oya } from '@oya-ai/browser';
|
|
61
|
+
|
|
62
|
+
const oya = new Oya();
|
|
63
|
+
const persona = await oya.personas.create({ name: 'billing-admin' });
|
|
64
|
+
await oya.personas.setMfa(persona.id, { type: 'totp', secret: process.env.TOTP_SECRET! }); // sealed, never read back
|
|
65
|
+
|
|
66
|
+
await using browser = await oya.browser.start({ persona: persona.id });
|
|
67
|
+
await browser.goto(process.env.MFA_URL!); // after your login step: the page asking for the code
|
|
68
|
+
const mfa = await browser.completeMfa(); // method: 'totp' | 'email' | 'sms' | 'handoff'
|
|
69
|
+
if (!mfa.completed) console.log('A person can finish it here:', mfa.liveViewUrl);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Playwright, Puppeteer, Stagehand
|
|
73
|
+
|
|
74
|
+
`browser.cdpUrl` is a standard CDP endpoint on any CDP vendor.
|
|
49
75
|
|
|
50
76
|
```ts
|
|
51
77
|
import { chromium } from 'playwright-core';
|
|
78
|
+
import { Oya } from '@oya-ai/browser';
|
|
52
79
|
|
|
53
|
-
|
|
54
|
-
|
|
80
|
+
const oya = new Oya();
|
|
81
|
+
await using browser = await oya.browser.start({ provider: 'browserbase' }); // or steel, anchor, browseruse
|
|
82
|
+
const context = (await chromium.connectOverCDP(browser.cdpUrl!)).contexts()[0];
|
|
83
|
+
const page = context.pages()[0] ?? await context.newPage();
|
|
84
|
+
await page.goto('https://example.com');
|
|
85
|
+
console.log(await page.title());
|
|
55
86
|
```
|
|
56
87
|
|
|
88
|
+
Vendor keys are set once on your Oya key in the dashboard. They never appear in code.
|
|
89
|
+
|
|
57
90
|
## API
|
|
58
91
|
|
|
59
92
|
| | |
|