Skip to content

Commit 1b573ff

Browse files
committed
Rename client variable to reader in all code examples
1 parent 5465ca0 commit 1b573ff

35 files changed

Lines changed: 150 additions & 150 deletions

api-reference/jobs/stream.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Stream events for a single job over a long-lived HTTP connection. Events fire as
1414
| `error` | `{ url, error }`: a single page failed |
1515
| `done` | `{ status, completed, total }`: final event, stream closes |
1616

17-
The SDK clients wrap this as `client.stream(jobId)` returning an async iterator. See [SSE streaming](/home/guides/async-workflows/sse-streaming).
17+
The SDK clients wrap this as `reader.stream(jobId)` returning an async iterator. See [SSE streaming](/home/guides/async-workflows/sse-streaming).
1818

1919
For a workspace-wide stream of every job's events, use [`GET /v1/events`](/api-reference/jobs/events) instead.

api-reference/sessions/cdp.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The WebSocket proxy authenticates via the `token` query parameter (not the API k
2222
## Playwright
2323

2424
```typescript
25-
const session = await client.sessions.create();
25+
const session = await reader.sessions.create();
2626
const browser = await chromium.connectOverCDP(session.wsEndpoint);
2727
const context = await browser.newContext();
2828
const page = await context.newPage();
@@ -39,7 +39,7 @@ const cookies = await context.cookies();
3939
## Puppeteer
4040

4141
```typescript
42-
const session = await client.sessions.create();
42+
const session = await reader.sessions.create();
4343
const browser = await connect({
4444
browserWSEndpoint: session.wsEndpoint,
4545
defaultViewport: null,

api-reference/sessions/create.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ Create a stealthed browser session. Returns a WebSocket URL for Playwright/Puppe
6161
### Playwright
6262

6363
```typescript
64-
const session = await client.sessions.create();
64+
const session = await reader.sessions.create();
6565
const browser = await chromium.connectOverCDP(session.wsEndpoint);
6666
```
6767

6868
### Puppeteer
6969

7070
```typescript
71-
const session = await client.sessions.create();
71+
const session = await reader.sessions.create();
7272
const browser = await connect({ browserWSEndpoint: session.wsEndpoint });
7373
```
7474

home/concepts/async-jobs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Fetch `GET /v1/jobs/{id}` every few seconds until `status` is terminal. Simplest
6161

6262
```ts
6363
while (true) {
64-
const { job } = await client.getJob(jobId);
64+
const { job } = await reader.getJob(jobId);
6565
if (["completed", "failed", "cancelled"].includes(job.status)) break;
6666
await sleep(2000);
6767
}

home/concepts/browser-sessions.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ The browser has anti-bot stealth active: `navigator.webdriver = false`, navigato
3333
import { ReaderClient } from "@vakra-dev/reader-js";
3434
import { chromium } from "playwright-core";
3535

36-
const client = new ReaderClient({ apiKey: process.env.READER_API_KEY });
36+
const reader = new ReaderClient({ apiKey: process.env.READER_API_KEY });
3737

3838
// One API call to create a stealthed browser
39-
const session = await client.sessions.create();
39+
const session = await reader.sessions.create();
4040

4141
// One-line change from a local Playwright script
4242
const browser = await chromium.connectOverCDP(session.wsEndpoint);
@@ -47,7 +47,7 @@ console.log(await page.title());
4747

4848
// Cleanup
4949
await browser.close();
50-
await client.sessions.stop(session.sessionId);
50+
await reader.sessions.stop(session.sessionId);
5151
```
5252

5353
## Stealth Features

home/concepts/credits-and-billing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ curl https://api.reader.dev/v1/usage/credits -H "x-api-key: $READER_KEY"
4343
Check programmatically from the SDK:
4444

4545
```ts
46-
const credits = await client.getCredits();
46+
const credits = await reader.getCredits();
4747
if (credits.balance < 100) {
4848
console.warn("Low credits, resets at", credits.resetAt);
4949
}

home/concepts/events.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The stream terminates automatically when the job reaches a terminal state.
4141
Use the SDK's `stream(jobId)` generator if you're in TypeScript:
4242

4343
```ts
44-
for await (const event of client.stream(jobId)) {
44+
for await (const event of reader.stream(jobId)) {
4545
if (event.type === "page") handlePage(event.data);
4646
if (event.type === "done") break;
4747
}

home/concepts/scrape-vs-crawl.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ A rule of thumb:
8484
A crawl result and a batch result are the same thing as far as your code is concerned: a job with a `results` array where each entry is one page. You can write one handler and point it at either.
8585

8686
```ts
87-
const result = await client.read({ urls: [...] }); // batch
87+
const result = await reader.read({ urls: [...] }); // batch
8888
// or
89-
const result = await client.read({ url, maxPages: 100 }); // crawl
89+
const result = await reader.read({ url, maxPages: 100 }); // crawl
9090

9191
if (result.kind === "job") {
9292
for (const page of result.data.results) {

home/guides/advanced/auth-walls.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Some pages won't load for any non-human request no matter what you do. Others wo
1717
For these, set `proxyMode: "stealth"` explicitly (or let `auto` handle it) and you'll usually get clean content:
1818

1919
```ts
20-
await client.read({
20+
await reader.read({
2121
url: "https://shop.example.com/item/42",
2222
proxyMode: "stealth", // 3 credits/page, bypasses bot walls
2323
});
@@ -49,7 +49,7 @@ If your scrapes are failing with `upstream_unavailable`, `scrape_timeout`, or ar
4949
When you know ahead of time a target is hostile (Amazon, LinkedIn, booking.com, ticketing sites, some news aggregators), skip the optimistic `auto` attempt and go straight to stealth:
5050

5151
```ts
52-
await client.read({
52+
await reader.read({
5353
url: "https://www.amazon.com/dp/B08N5WRWNW",
5454
proxyMode: "stealth",
5555
});

home/guides/advanced/batch-scraping.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ When you have a list of URLs (from a sitemap, an RSS feed, a search result, or y
88
## The basic request
99

1010
```ts
11-
const result = await client.read({
11+
const result = await reader.read({
1212
urls: [
1313
"https://example.com/article/1",
1414
"https://example.com/article/2",
@@ -36,7 +36,7 @@ A loop of sync scrapes eats your rate limit, your connection pool, and your pati
3636
```ts
3737
// One request per URL: don't do this
3838
for (const url of urls) {
39-
await client.read({ url });
39+
await reader.read({ url });
4040
}
4141
```
4242

@@ -47,7 +47,7 @@ The batch version is **one** API call. Reader handles parallelism internally and
4747
By default Reader picks a sensible parallelism level for your batch. For very large batches or target sites you want to be gentle with, set `batchConcurrency` explicitly:
4848

4949
```ts
50-
await client.read({
50+
await reader.read({
5151
urls: manyUrls,
5252
batchConcurrency: 5, // Reader runs up to 5 scrapes in parallel
5353
});
@@ -67,7 +67,7 @@ console.log(`${succeeded.length} succeeded, ${failed.length} failed`);
6767

6868
// Retry just the failed subset if needed
6969
if (failed.length > 0) {
70-
await client.retryJob(result.data.id);
70+
await reader.retryJob(result.data.id);
7171
// Reader re-queues the failed URLs and you get a fresh completion
7272
}
7373
```
@@ -86,7 +86,7 @@ const urls = Array.from(sitemapXml.matchAll(/<loc>([^<]+)<\/loc>/g)).map(
8686
// Submit in chunks of 1,000 (the max per request)
8787
for (let i = 0; i < urls.length; i += 1000) {
8888
const chunk = urls.slice(i, i + 1000);
89-
const result = await client.read({
89+
const result = await reader.read({
9090
urls: chunk,
9191
webhook: {
9292
url: "https://your-app.example.com/hooks/reader",

0 commit comments

Comments
 (0)