@upcrawl/sdk 1.3.1 → 1.4.1

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/dist/index.d.ts CHANGED
@@ -1,236 +1,349 @@
1
+ import { z } from 'zod';
2
+ import { AxiosInstance } from 'axios';
3
+
1
4
  /**
2
5
  * Upcrawl SDK Types
3
6
  * Type definitions for all API requests and responses
7
+ * Powered by Zod schemas — single source of truth for types, validation, and docs
4
8
  */
5
- interface UpcrawlConfig {
6
- apiKey?: string;
7
- baseUrl?: string;
8
- timeout?: number;
9
- }
10
- interface SummaryQuery {
11
- /** Query/instruction for content summarization */
12
- query: string;
13
- }
14
- interface ScrapeOptions {
15
- /** URL to scrape (required) */
16
- url: string;
17
- /** Output format: html or markdown. Defaults to "html" */
18
- type?: 'html' | 'markdown';
19
- /** Extract only main content (removes nav, ads, footers). Defaults to true */
20
- onlyMainContent?: boolean;
21
- /** Whether to extract page metadata */
22
- extractMetadata?: boolean;
23
- /** Summary query for LLM summarization */
24
- summary?: SummaryQuery;
25
- /** Custom timeout in milliseconds (1000-120000) */
26
- timeoutMs?: number;
27
- /** Wait strategy for page load */
28
- waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
29
- }
30
- interface ScrapeMetadata {
31
- title?: string;
32
- description?: string;
33
- canonicalUrl?: string;
34
- finalUrl?: string;
35
- contentType?: string;
36
- contentLength?: number;
37
- }
38
- interface ScrapeResponse {
39
- /** Original URL that was scraped */
40
- url: string;
41
- /** Rendered HTML content (when type is html) */
42
- html?: string | null;
43
- /** Content converted to Markdown (when type is markdown) */
44
- markdown?: string | null;
45
- /** HTTP status code */
46
- statusCode: number | null;
47
- /** Whether scraping was successful */
48
- success: boolean;
49
- /** Error message if scraping failed */
50
- error?: string;
51
- /** ISO timestamp when scraping completed */
52
- timestamp: string;
53
- /** Time taken to load and render the page in milliseconds */
54
- loadTimeMs: number;
55
- /** Additional page metadata */
56
- metadata?: ScrapeMetadata;
57
- /** Number of retry attempts made */
58
- retryCount: number;
59
- /** Cost in USD for this scrape operation */
60
- cost?: number;
61
- /** Content after summarization (when summary query provided) */
62
- content?: string | null;
63
- }
64
- interface BatchScrapeOptions {
65
- /** Array of URLs to scrape (strings or detailed request objects) */
66
- urls: (string | ScrapeOptions)[];
67
- /** Output format: html or markdown */
68
- type?: 'html' | 'markdown';
69
- /** Extract only main content (removes nav, ads, footers) */
70
- onlyMainContent?: boolean;
71
- /** Summary query for LLM summarization */
72
- summary?: SummaryQuery;
73
- /** Global timeout for entire batch operation in milliseconds (10000-600000) */
74
- batchTimeoutMs?: number;
75
- /** Whether to stop on first error */
76
- failFast?: boolean;
77
- }
78
- interface BatchScrapeResponse {
79
- /** Array of scrape results */
80
- results: ScrapeResponse[];
81
- /** Total number of URLs processed */
82
- total: number;
83
- /** Number of successful scrapes */
84
- successful: number;
85
- /** Number of failed scrapes */
86
- failed: number;
87
- /** Total time taken for batch operation in milliseconds */
88
- totalTimeMs: number;
89
- /** Timestamp when batch operation completed */
90
- timestamp: string;
91
- /** Total cost in USD for all scrape operations */
92
- cost?: number;
93
- }
94
- interface SearchOptions {
95
- /** Array of search queries to execute (1-20) */
96
- queries: string[];
97
- /** Number of results per query (1-100). Defaults to 10 */
98
- limit?: number;
99
- /** Location for search (e.g., "IN", "US") */
100
- location?: string;
101
- /** Domains to include (will add site: to query) */
102
- includeDomains?: string[];
103
- /** Domains to exclude (will add -site: to query) */
104
- excludeDomains?: string[];
105
- }
106
- interface SearchResultWeb {
107
- /** URL of the search result */
108
- url: string;
109
- /** Title of the search result */
110
- title: string;
111
- /** Description/snippet of the search result */
112
- description: string;
113
- }
114
- interface SearchResultItem {
115
- /** The search query */
116
- query: string;
117
- /** Whether the search was successful */
118
- success: boolean;
119
- /** Parsed search result links */
120
- results: SearchResultWeb[];
121
- /** Error message if failed */
122
- error?: string;
123
- /** Time taken in milliseconds */
124
- loadTimeMs?: number;
125
- /** Cost in USD for this query */
126
- cost?: number;
127
- }
128
- interface SearchResponse {
129
- /** Array of search results per query */
130
- results: SearchResultItem[];
131
- /** Total number of queries */
132
- total: number;
133
- /** Number of successful searches */
134
- successful: number;
135
- /** Number of failed searches */
136
- failed: number;
137
- /** Total time in milliseconds */
138
- totalTimeMs: number;
139
- /** ISO timestamp */
140
- timestamp: string;
141
- /** Total cost in USD */
142
- cost?: number;
143
- }
144
- interface PdfMargin {
145
- top?: string;
146
- right?: string;
147
- bottom?: string;
148
- left?: string;
149
- }
150
- interface GeneratePdfOptions {
151
- /** Complete HTML content to convert to PDF (required) */
152
- html: string;
153
- /** Title used for the exported filename */
154
- title?: string;
155
- /** Page size. Defaults to "A4" */
156
- pageSize?: 'A4' | 'Letter' | 'Legal';
157
- /** Landscape orientation. Defaults to false */
158
- landscape?: boolean;
159
- /** Page margins (e.g., { top: '20mm', right: '20mm', bottom: '20mm', left: '20mm' }) */
160
- margin?: PdfMargin;
161
- /** Print background graphics and colors. Defaults to true */
162
- printBackground?: boolean;
163
- /** Skip waiting for chart rendering signal. Defaults to false */
164
- skipChartWait?: boolean;
165
- /** Timeout in milliseconds (5000-120000). Defaults to 30000 */
166
- timeoutMs?: number;
167
- }
168
- interface GeneratePdfFromUrlOptions {
169
- /** URL to navigate to and convert to PDF (required) */
170
- url: string;
171
- /** Title used for the exported filename */
172
- title?: string;
173
- /** Page size. Defaults to "A4" */
174
- pageSize?: 'A4' | 'Letter' | 'Legal';
175
- /** Landscape orientation. Defaults to false */
176
- landscape?: boolean;
177
- /** Page margins */
178
- margin?: PdfMargin;
179
- /** Print background graphics and colors. Defaults to true */
180
- printBackground?: boolean;
181
- /** Timeout in milliseconds (5000-120000). Defaults to 30000 */
182
- timeoutMs?: number;
183
- }
184
- interface PdfResponse {
185
- /** Whether PDF generation succeeded */
186
- success: boolean;
187
- /** Public URL of the generated PDF */
188
- url?: string;
189
- /** Generated filename */
190
- filename?: string;
191
- /** Blob storage path */
192
- blobName?: string;
193
- /** Error message on failure */
194
- error?: string;
195
- /** Total time taken in milliseconds */
196
- durationMs: number;
197
- }
198
- interface ExecuteCodeOptions {
199
- /** Code to execute (required) */
200
- code: string;
201
- /** Language runtime. Defaults to "python" */
202
- language?: 'python';
203
- }
204
- interface ExecuteCodeResponse {
205
- /** Standard output from the executed code */
206
- stdout: string;
207
- /** Standard error from the executed code */
208
- stderr: string;
209
- /** Process exit code (0 = success, 124 = timeout) */
210
- exitCode: number;
211
- /** Execution time in milliseconds */
212
- executionTimeMs: number;
213
- /** Whether execution was killed due to timeout */
214
- timedOut: boolean;
215
- /** Peak memory usage in megabytes */
216
- memoryUsageMb?: number;
217
- /** Error message if execution infrastructure failed */
218
- error?: string;
219
- /** Cost in USD for this execution */
220
- cost?: number;
221
- }
222
- interface UpcrawlErrorResponse {
223
- error: {
224
- code: string;
225
- message: string;
226
- };
227
- statusCode?: number;
228
- }
9
+
10
+ declare const UpcrawlConfigSchema: z.ZodObject<{
11
+ apiKey: z.ZodOptional<z.ZodString>;
12
+ baseUrl: z.ZodOptional<z.ZodString>;
13
+ timeout: z.ZodOptional<z.ZodNumber>;
14
+ }, z.core.$strip>;
15
+ type UpcrawlConfig = z.infer<typeof UpcrawlConfigSchema>;
16
+ declare const SummaryQuerySchema: z.ZodObject<{
17
+ query: z.ZodString;
18
+ }, z.core.$strip>;
19
+ type SummaryQuery = z.infer<typeof SummaryQuerySchema>;
20
+ declare const ScrapeOptionsSchema: z.ZodObject<{
21
+ url: z.ZodString;
22
+ type: z.ZodOptional<z.ZodEnum<{
23
+ html: "html";
24
+ markdown: "markdown";
25
+ }>>;
26
+ onlyMainContent: z.ZodOptional<z.ZodBoolean>;
27
+ extractMetadata: z.ZodOptional<z.ZodBoolean>;
28
+ summary: z.ZodOptional<z.ZodObject<{
29
+ query: z.ZodString;
30
+ }, z.core.$strip>>;
31
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
32
+ waitUntil: z.ZodOptional<z.ZodEnum<{
33
+ load: "load";
34
+ domcontentloaded: "domcontentloaded";
35
+ networkidle: "networkidle";
36
+ }>>;
37
+ }, z.core.$strip>;
38
+ type ScrapeOptions = z.infer<typeof ScrapeOptionsSchema>;
39
+ declare const ScrapeMetadataSchema: z.ZodObject<{
40
+ title: z.ZodOptional<z.ZodString>;
41
+ description: z.ZodOptional<z.ZodString>;
42
+ canonicalUrl: z.ZodOptional<z.ZodString>;
43
+ finalUrl: z.ZodOptional<z.ZodString>;
44
+ contentType: z.ZodOptional<z.ZodString>;
45
+ contentLength: z.ZodOptional<z.ZodNumber>;
46
+ }, z.core.$strip>;
47
+ type ScrapeMetadata = z.infer<typeof ScrapeMetadataSchema>;
48
+ declare const ScrapeResponseSchema: z.ZodObject<{
49
+ url: z.ZodString;
50
+ html: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ markdown: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ statusCode: z.ZodNullable<z.ZodNumber>;
53
+ success: z.ZodBoolean;
54
+ error: z.ZodOptional<z.ZodString>;
55
+ timestamp: z.ZodString;
56
+ loadTimeMs: z.ZodNumber;
57
+ metadata: z.ZodOptional<z.ZodObject<{
58
+ title: z.ZodOptional<z.ZodString>;
59
+ description: z.ZodOptional<z.ZodString>;
60
+ canonicalUrl: z.ZodOptional<z.ZodString>;
61
+ finalUrl: z.ZodOptional<z.ZodString>;
62
+ contentType: z.ZodOptional<z.ZodString>;
63
+ contentLength: z.ZodOptional<z.ZodNumber>;
64
+ }, z.core.$strip>>;
65
+ retryCount: z.ZodNumber;
66
+ cost: z.ZodOptional<z.ZodNumber>;
67
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
+ }, z.core.$strip>;
69
+ type ScrapeResponse = z.infer<typeof ScrapeResponseSchema>;
70
+ declare const BatchScrapeOptionsSchema: z.ZodObject<{
71
+ urls: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
72
+ url: z.ZodString;
73
+ type: z.ZodOptional<z.ZodEnum<{
74
+ html: "html";
75
+ markdown: "markdown";
76
+ }>>;
77
+ onlyMainContent: z.ZodOptional<z.ZodBoolean>;
78
+ extractMetadata: z.ZodOptional<z.ZodBoolean>;
79
+ summary: z.ZodOptional<z.ZodObject<{
80
+ query: z.ZodString;
81
+ }, z.core.$strip>>;
82
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
83
+ waitUntil: z.ZodOptional<z.ZodEnum<{
84
+ load: "load";
85
+ domcontentloaded: "domcontentloaded";
86
+ networkidle: "networkidle";
87
+ }>>;
88
+ }, z.core.$strip>]>>;
89
+ type: z.ZodOptional<z.ZodEnum<{
90
+ html: "html";
91
+ markdown: "markdown";
92
+ }>>;
93
+ onlyMainContent: z.ZodOptional<z.ZodBoolean>;
94
+ summary: z.ZodOptional<z.ZodObject<{
95
+ query: z.ZodString;
96
+ }, z.core.$strip>>;
97
+ batchTimeoutMs: z.ZodOptional<z.ZodNumber>;
98
+ failFast: z.ZodOptional<z.ZodBoolean>;
99
+ }, z.core.$strip>;
100
+ type BatchScrapeOptions = z.infer<typeof BatchScrapeOptionsSchema>;
101
+ declare const BatchScrapeResponseSchema: z.ZodObject<{
102
+ results: z.ZodArray<z.ZodObject<{
103
+ url: z.ZodString;
104
+ html: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
+ markdown: z.ZodOptional<z.ZodNullable<z.ZodString>>;
106
+ statusCode: z.ZodNullable<z.ZodNumber>;
107
+ success: z.ZodBoolean;
108
+ error: z.ZodOptional<z.ZodString>;
109
+ timestamp: z.ZodString;
110
+ loadTimeMs: z.ZodNumber;
111
+ metadata: z.ZodOptional<z.ZodObject<{
112
+ title: z.ZodOptional<z.ZodString>;
113
+ description: z.ZodOptional<z.ZodString>;
114
+ canonicalUrl: z.ZodOptional<z.ZodString>;
115
+ finalUrl: z.ZodOptional<z.ZodString>;
116
+ contentType: z.ZodOptional<z.ZodString>;
117
+ contentLength: z.ZodOptional<z.ZodNumber>;
118
+ }, z.core.$strip>>;
119
+ retryCount: z.ZodNumber;
120
+ cost: z.ZodOptional<z.ZodNumber>;
121
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
122
+ }, z.core.$strip>>;
123
+ total: z.ZodNumber;
124
+ successful: z.ZodNumber;
125
+ failed: z.ZodNumber;
126
+ totalTimeMs: z.ZodNumber;
127
+ timestamp: z.ZodString;
128
+ cost: z.ZodOptional<z.ZodNumber>;
129
+ }, z.core.$strip>;
130
+ type BatchScrapeResponse = z.infer<typeof BatchScrapeResponseSchema>;
131
+ declare const SearchOptionsSchema: z.ZodObject<{
132
+ queries: z.ZodArray<z.ZodString>;
133
+ limit: z.ZodOptional<z.ZodNumber>;
134
+ location: z.ZodOptional<z.ZodString>;
135
+ includeDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
136
+ excludeDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
137
+ }, z.core.$strip>;
138
+ type SearchOptions = z.infer<typeof SearchOptionsSchema>;
139
+ declare const SearchResultWebSchema: z.ZodObject<{
140
+ url: z.ZodString;
141
+ title: z.ZodString;
142
+ description: z.ZodString;
143
+ }, z.core.$strip>;
144
+ type SearchResultWeb = z.infer<typeof SearchResultWebSchema>;
145
+ declare const SearchResultItemSchema: z.ZodObject<{
146
+ query: z.ZodString;
147
+ success: z.ZodBoolean;
148
+ results: z.ZodArray<z.ZodObject<{
149
+ url: z.ZodString;
150
+ title: z.ZodString;
151
+ description: z.ZodString;
152
+ }, z.core.$strip>>;
153
+ error: z.ZodOptional<z.ZodString>;
154
+ loadTimeMs: z.ZodOptional<z.ZodNumber>;
155
+ cost: z.ZodOptional<z.ZodNumber>;
156
+ }, z.core.$strip>;
157
+ type SearchResultItem = z.infer<typeof SearchResultItemSchema>;
158
+ declare const SearchResponseSchema: z.ZodObject<{
159
+ results: z.ZodArray<z.ZodObject<{
160
+ query: z.ZodString;
161
+ success: z.ZodBoolean;
162
+ results: z.ZodArray<z.ZodObject<{
163
+ url: z.ZodString;
164
+ title: z.ZodString;
165
+ description: z.ZodString;
166
+ }, z.core.$strip>>;
167
+ error: z.ZodOptional<z.ZodString>;
168
+ loadTimeMs: z.ZodOptional<z.ZodNumber>;
169
+ cost: z.ZodOptional<z.ZodNumber>;
170
+ }, z.core.$strip>>;
171
+ total: z.ZodNumber;
172
+ successful: z.ZodNumber;
173
+ failed: z.ZodNumber;
174
+ totalTimeMs: z.ZodNumber;
175
+ timestamp: z.ZodString;
176
+ cost: z.ZodOptional<z.ZodNumber>;
177
+ }, z.core.$strip>;
178
+ type SearchResponse = z.infer<typeof SearchResponseSchema>;
179
+ declare const PdfMarginSchema: z.ZodObject<{
180
+ top: z.ZodOptional<z.ZodString>;
181
+ right: z.ZodOptional<z.ZodString>;
182
+ bottom: z.ZodOptional<z.ZodString>;
183
+ left: z.ZodOptional<z.ZodString>;
184
+ }, z.core.$strip>;
185
+ type PdfMargin = z.infer<typeof PdfMarginSchema>;
186
+ declare const GeneratePdfOptionsSchema: z.ZodObject<{
187
+ html: z.ZodString;
188
+ title: z.ZodOptional<z.ZodString>;
189
+ pageSize: z.ZodOptional<z.ZodEnum<{
190
+ A4: "A4";
191
+ Letter: "Letter";
192
+ Legal: "Legal";
193
+ }>>;
194
+ landscape: z.ZodOptional<z.ZodBoolean>;
195
+ margin: z.ZodOptional<z.ZodObject<{
196
+ top: z.ZodOptional<z.ZodString>;
197
+ right: z.ZodOptional<z.ZodString>;
198
+ bottom: z.ZodOptional<z.ZodString>;
199
+ left: z.ZodOptional<z.ZodString>;
200
+ }, z.core.$strip>>;
201
+ printBackground: z.ZodOptional<z.ZodBoolean>;
202
+ skipChartWait: z.ZodOptional<z.ZodBoolean>;
203
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
204
+ }, z.core.$strip>;
205
+ type GeneratePdfOptions = z.infer<typeof GeneratePdfOptionsSchema>;
206
+ declare const GeneratePdfFromUrlOptionsSchema: z.ZodObject<{
207
+ url: z.ZodString;
208
+ title: z.ZodOptional<z.ZodString>;
209
+ pageSize: z.ZodOptional<z.ZodEnum<{
210
+ A4: "A4";
211
+ Letter: "Letter";
212
+ Legal: "Legal";
213
+ }>>;
214
+ landscape: z.ZodOptional<z.ZodBoolean>;
215
+ margin: z.ZodOptional<z.ZodObject<{
216
+ top: z.ZodOptional<z.ZodString>;
217
+ right: z.ZodOptional<z.ZodString>;
218
+ bottom: z.ZodOptional<z.ZodString>;
219
+ left: z.ZodOptional<z.ZodString>;
220
+ }, z.core.$strip>>;
221
+ printBackground: z.ZodOptional<z.ZodBoolean>;
222
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
223
+ }, z.core.$strip>;
224
+ type GeneratePdfFromUrlOptions = z.infer<typeof GeneratePdfFromUrlOptionsSchema>;
225
+ declare const PdfResponseSchema: z.ZodObject<{
226
+ success: z.ZodBoolean;
227
+ url: z.ZodOptional<z.ZodString>;
228
+ filename: z.ZodOptional<z.ZodString>;
229
+ blobName: z.ZodOptional<z.ZodString>;
230
+ error: z.ZodOptional<z.ZodString>;
231
+ durationMs: z.ZodNumber;
232
+ }, z.core.$strip>;
233
+ type PdfResponse = z.infer<typeof PdfResponseSchema>;
234
+ declare const ExecuteCodeOptionsSchema: z.ZodObject<{
235
+ code: z.ZodString;
236
+ language: z.ZodOptional<z.ZodEnum<{
237
+ python: "python";
238
+ }>>;
239
+ }, z.core.$strip>;
240
+ type ExecuteCodeOptions = z.infer<typeof ExecuteCodeOptionsSchema>;
241
+ declare const ExecuteCodeResponseSchema: z.ZodObject<{
242
+ stdout: z.ZodString;
243
+ stderr: z.ZodString;
244
+ exitCode: z.ZodNumber;
245
+ executionTimeMs: z.ZodNumber;
246
+ timedOut: z.ZodBoolean;
247
+ memoryUsageMb: z.ZodOptional<z.ZodNumber>;
248
+ error: z.ZodOptional<z.ZodString>;
249
+ cost: z.ZodOptional<z.ZodNumber>;
250
+ }, z.core.$strip>;
251
+ type ExecuteCodeResponse = z.infer<typeof ExecuteCodeResponseSchema>;
252
+ declare const UpcrawlErrorResponseSchema: z.ZodObject<{
253
+ error: z.ZodObject<{
254
+ code: z.ZodString;
255
+ message: z.ZodString;
256
+ }, z.core.$strip>;
257
+ statusCode: z.ZodOptional<z.ZodNumber>;
258
+ }, z.core.$strip>;
259
+ type UpcrawlErrorResponse = z.infer<typeof UpcrawlErrorResponseSchema>;
229
260
  declare class UpcrawlError extends Error {
230
261
  readonly status: number;
231
262
  readonly code: string;
232
263
  constructor(message: string, status: number, code?: string);
233
264
  }
265
+ declare const CreateBrowserSessionOptionsSchema: z.ZodObject<{
266
+ width: z.ZodOptional<z.ZodNumber>;
267
+ height: z.ZodOptional<z.ZodNumber>;
268
+ headless: z.ZodOptional<z.ZodBoolean>;
269
+ }, z.core.$strip>;
270
+ type CreateBrowserSessionOptions = z.infer<typeof CreateBrowserSessionOptionsSchema>;
271
+ declare const BrowserSessionSchema: z.ZodObject<{
272
+ sessionId: z.ZodString;
273
+ wsEndpoint: z.ZodString;
274
+ vncUrl: z.ZodNullable<z.ZodString>;
275
+ affinityCookie: z.ZodOptional<z.ZodString>;
276
+ createdAt: z.ZodDate;
277
+ width: z.ZodNumber;
278
+ height: z.ZodNumber;
279
+ }, z.core.$strip>;
280
+ type BrowserSession = z.infer<typeof BrowserSessionSchema>;
281
+
282
+ /**
283
+ * Upcrawl Browser Namespace
284
+ * Manage browser sessions for remote control with Playwright/Puppeteer
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * import Upcrawl from '@upcrawl/sdk';
289
+ * import playwright from 'playwright-core';
290
+ *
291
+ * const upcrawl = new Upcrawl('uc-your-api-key');
292
+ *
293
+ * // Create a browser session
294
+ * const session = await upcrawl.browser.create({
295
+ * width: 1280,
296
+ * height: 720,
297
+ * headless: true
298
+ * });
299
+ *
300
+ * // Connect with Playwright
301
+ * const browser = await playwright.connect(session.wsEndpoint);
302
+ * const page = await browser.newPage();
303
+ * await page.goto('https://example.com');
304
+ *
305
+ * // Close the session when done
306
+ * await upcrawl.browser.close(session.sessionId);
307
+ * ```
308
+ */
309
+
310
+ declare class Browser {
311
+ private createClient;
312
+ constructor(createClient: () => AxiosInstance);
313
+ /**
314
+ * Create a new browser session for remote control
315
+ * @param options - Session options including viewport size and headless mode
316
+ * @returns Promise with session details including WebSocket URL
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * const session = await upcrawl.browser.create({
321
+ * width: 1280,
322
+ * height: 720,
323
+ * headless: true
324
+ * });
325
+ *
326
+ * console.log(session.wsEndpoint); // WebSocket URL for Playwright
327
+ * console.log(session.vncUrl); // VNC URL for viewing (if available)
328
+ * ```
329
+ */
330
+ create(options?: CreateBrowserSessionOptions): Promise<BrowserSession>;
331
+ /**
332
+ * Close a browser session
333
+ * @param sessionId - The session ID to close
334
+ * @returns Promise that resolves when session is closed
335
+ *
336
+ * @example
337
+ * ```typescript
338
+ * await upcrawl.browser.close(session.sessionId);
339
+ * ```
340
+ */
341
+ close(sessionId: string): Promise<void>;
342
+ /**
343
+ * Handle API errors and convert to UpcrawlError
344
+ */
345
+ private handleError;
346
+ }
234
347
 
235
348
  /**
236
349
  * Upcrawl API Client
@@ -525,10 +638,27 @@ declare const Upcrawl: {
525
638
  * @returns Promise with execution response (stdout, stderr, exit code, memory usage)
526
639
  */
527
640
  readonly executeCode: typeof executeCode;
641
+ /**
642
+ * Browser session management
643
+ * Create and manage browser sessions for remote control with Playwright/Puppeteer
644
+ *
645
+ * @example
646
+ * ```typescript
647
+ * const session = await Upcrawl.browser.create({
648
+ * width: 1280,
649
+ * height: 720,
650
+ * headless: true
651
+ * });
652
+ *
653
+ * const browser = await playwright.connect(session.wsEndpoint);
654
+ * await upcrawl.browser.close(session.sessionId);
655
+ * ```
656
+ */
657
+ readonly browser: Browser;
528
658
  /**
529
659
  * Error class for Upcrawl API errors
530
660
  */
531
661
  readonly UpcrawlError: typeof UpcrawlError;
532
662
  };
533
663
 
534
- export { type BatchScrapeOptions, type BatchScrapeResponse, type ExecuteCodeOptions, type ExecuteCodeResponse, type GeneratePdfFromUrlOptions, type GeneratePdfOptions, type PdfMargin, type PdfResponse, type ScrapeMetadata, type ScrapeOptions, type ScrapeResponse, type SearchOptions, type SearchResponse, type SearchResultItem, type SearchResultWeb, type SummaryQuery, type UpcrawlConfig, UpcrawlError, type UpcrawlErrorResponse, batchScrape, configure, Upcrawl as default, executeCode, generatePdf, generatePdfFromUrl, getConfig, resetConfig, scrape, search, setApiKey, setBaseUrl, setTimeout };
664
+ export { type BatchScrapeOptions, BatchScrapeOptionsSchema, type BatchScrapeResponse, BatchScrapeResponseSchema, Browser, type BrowserSession, BrowserSessionSchema, type CreateBrowserSessionOptions, CreateBrowserSessionOptionsSchema, type ExecuteCodeOptions, ExecuteCodeOptionsSchema, type ExecuteCodeResponse, ExecuteCodeResponseSchema, type GeneratePdfFromUrlOptions, GeneratePdfFromUrlOptionsSchema, type GeneratePdfOptions, GeneratePdfOptionsSchema, type PdfMargin, PdfMarginSchema, type PdfResponse, PdfResponseSchema, type ScrapeMetadata, ScrapeMetadataSchema, type ScrapeOptions, ScrapeOptionsSchema, type ScrapeResponse, ScrapeResponseSchema, type SearchOptions, SearchOptionsSchema, type SearchResponse, SearchResponseSchema, type SearchResultItem, SearchResultItemSchema, type SearchResultWeb, SearchResultWebSchema, type SummaryQuery, SummaryQuerySchema, type UpcrawlConfig, UpcrawlConfigSchema, UpcrawlError, type UpcrawlErrorResponse, UpcrawlErrorResponseSchema, batchScrape, configure, Upcrawl as default, executeCode, generatePdf, generatePdfFromUrl, getConfig, resetConfig, scrape, search, setApiKey, setBaseUrl, setTimeout };