@monostate/browsernative-client 1.0.2 → 1.1.0

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 CHANGED
@@ -37,19 +37,26 @@ const client = new BrowserNativeClient('your-api-key');
37
37
  const result = await client.scrape('https://example.com');
38
38
  console.log(result.data.title);
39
39
  console.log(result.data.content);
40
+
41
+ // Quick screenshot capture (optimized for speed)
42
+ const screenshot = await client.quickshot('https://example.com');
43
+ console.log(screenshot.screenshot); // Base64 image
40
44
  ```
41
45
 
42
46
  ### Quick Functions
43
47
 
44
48
  ```javascript
45
- import { quickScrape, quickScreenshot, quickAnalyze } from '@browsernative/client';
49
+ import { quickScrape, quickScreenshot, quickShot, quickAnalyze } from '@browsernative/client';
46
50
 
47
51
  // One-line scraping
48
52
  const content = await quickScrape('https://example.com', 'your-api-key');
49
53
 
50
- // Take a screenshot
54
+ // Take a screenshot (with content extraction)
51
55
  const screenshot = await quickScreenshot('https://example.com', 'your-api-key');
52
56
 
57
+ // Quick screenshot only (fastest option)
58
+ const quickScreenshot = await quickShot('https://example.com', 'your-api-key');
59
+
53
60
  // AI-powered analysis
54
61
  const analysis = await quickAnalyze(
55
62
  'https://news.ycombinator.com',
@@ -67,7 +74,7 @@ const client = new BrowserNativeClient(apiKey, options);
67
74
  ```
68
75
 
69
76
  **Options:**
70
- - `baseUrl` (string): API base URL (default: `https://browsernative.monostate.ai`)
77
+ - `baseUrl` (string): API base URL (default: `https://bnca-api.fly.dev`)
71
78
  - `timeout` (number): Request timeout in ms (default: `30000`)
72
79
  - `retries` (number): Number of retry attempts (default: `2`)
73
80
  - `verbose` (boolean): Enable logging (default: `false`)
@@ -102,7 +109,7 @@ console.log(result.method); // Scraping method used
102
109
 
103
110
  #### `client.screenshot(url, options)`
104
111
 
105
- Take high-quality screenshots of webpages.
112
+ Take high-quality screenshots of webpages with content extraction.
106
113
 
107
114
  ```javascript
108
115
  const result = await client.screenshot('https://example.com', {
@@ -121,6 +128,24 @@ const img = `data:image/png;base64,${result.screenshot}`;
121
128
  - `quality` (number): JPEG quality (1-100)
122
129
  - All scrape options are also available
123
130
 
131
+ #### `client.quickshot(url, options)`
132
+
133
+ Optimized screenshot capture for maximum speed (no content extraction).
134
+
135
+ ```javascript
136
+ const result = await client.quickshot('https://example.com');
137
+
138
+ // Returns screenshot immediately
139
+ if (result.success && result.screenshot) {
140
+ const img = result.screenshot; // Already includes data:image/png;base64,
141
+ }
142
+ ```
143
+
144
+ **Benefits:**
145
+ - 2-3x faster than regular screenshot
146
+ - Optimized for visual capture only
147
+ - Perfect for thumbnails and previews
148
+
124
149
  #### `client.analyze(url, question, options)`
125
150
 
126
151
  AI-powered content analysis and question answering.
package/index.d.ts CHANGED
@@ -143,6 +143,11 @@ export declare class BrowserNativeClient {
143
143
  */
144
144
  screenshot(url: string, options?: ScreenshotOptions): Promise<ScrapeResult>;
145
145
 
146
+ /**
147
+ * Quick screenshot capture - optimized for speed
148
+ */
149
+ quickshot(url: string, options?: ScreenshotOptions): Promise<ScrapeResult>;
150
+
146
151
  /**
147
152
  * Extract content and answer questions using AI
148
153
  */
@@ -187,4 +192,13 @@ export declare function quickAnalyze(
187
192
  options?: AnalyzeOptions
188
193
  ): Promise<AnalyzeResult>;
189
194
 
195
+ /**
196
+ * Convenience function for quick screenshot capture
197
+ */
198
+ export declare function quickShot(
199
+ url: string,
200
+ apiKey: string,
201
+ options?: ScreenshotOptions
202
+ ): Promise<ScrapeResult>;
203
+
190
204
  export default BrowserNativeClient;
package/index.js CHANGED
@@ -50,6 +50,21 @@ export class BrowserNativeClient {
50
50
  return this._makeRequest('/scrapeurl', payload);
51
51
  }
52
52
 
53
+ /**
54
+ * Quick screenshot capture - optimized for speed
55
+ * @param {string} url - The URL to capture
56
+ * @param {object} options - Screenshot options
57
+ * @returns {Promise<object>} Screenshot result
58
+ */
59
+ async quickshot(url, options = {}) {
60
+ const payload = {
61
+ url,
62
+ ...options
63
+ };
64
+
65
+ return this._makeRequest('/quickshot', payload);
66
+ }
67
+
53
68
  /**
54
69
  * Extract content and answer questions using AI
55
70
  * @param {string} url - The URL to analyze
@@ -104,9 +119,9 @@ export class BrowserNativeClient {
104
119
  const options = {
105
120
  method,
106
121
  headers: {
107
- 'Authorization': `Bearer ${this.apiKey}`,
122
+ 'x-api-key': this.apiKey,
108
123
  'Content-Type': 'application/json',
109
- 'User-Agent': 'Browser Native Client SDK/1.0.0'
124
+ 'User-Agent': 'Browser Native Client SDK/1.0.3'
110
125
  }
111
126
  };
112
127
 
@@ -204,5 +219,17 @@ export async function quickAnalyze(url, question, apiKey, options = {}) {
204
219
  return client.analyze(url, question, options);
205
220
  }
206
221
 
222
+ /**
223
+ * Convenience function for quick screenshot capture
224
+ * @param {string} url - The URL to capture
225
+ * @param {string} apiKey - Your API key
226
+ * @param {object} options - Additional options
227
+ * @returns {Promise<object>} Screenshot result
228
+ */
229
+ export async function quickShot(url, apiKey, options = {}) {
230
+ const client = new BrowserNativeClient(apiKey, options);
231
+ return client.quickshot(url, options);
232
+ }
233
+
207
234
  // Default export for CommonJS compatibility
208
235
  export default BrowserNativeClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monostate/browsernative-client",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Browser Native client SDK for web scraping and content extraction API",
5
5
  "type": "module",
6
6
  "main": "index.js",