@upcrawl/sdk 1.0.0 → 1.2.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/README.md CHANGED
@@ -1,23 +1,25 @@
1
- # Upcrawl
1
+ ![Upcrawl](https://upcrawlassets.blob.core.windows.net/assets/readme.png)
2
+
3
+ # @upcrawl/sdk
2
4
 
3
5
  Official Node.js/Browser SDK for the [Upcrawl](https://upcrawl.dev) API. Extract data from any website with a single API call.
4
6
 
5
7
  ## Installation
6
8
 
7
9
  ```bash
8
- npm install upcrawl
10
+ npm install @upcrawl/sdk
9
11
  ```
10
12
 
11
13
  Or with yarn:
12
14
 
13
15
  ```bash
14
- yarn add upcrawl
16
+ yarn add @upcrawl/sdk
15
17
  ```
16
18
 
17
19
  ## Quick Start
18
20
 
19
21
  ```typescript
20
- import Upcrawl from 'upcrawl';
22
+ import Upcrawl from '@upcrawl/sdk';
21
23
 
22
24
  // Set your API key (get one at https://upcrawl.dev)
23
25
  Upcrawl.setApiKey('uc-your-api-key');
@@ -38,7 +40,7 @@ console.log(result.markdown);
38
40
  The API key must be set before making any requests:
39
41
 
40
42
  ```typescript
41
- import Upcrawl from 'upcrawl';
43
+ import Upcrawl from '@upcrawl/sdk';
42
44
 
43
45
  Upcrawl.setApiKey('uc-your-api-key');
44
46
  ```
@@ -46,7 +48,7 @@ Upcrawl.setApiKey('uc-your-api-key');
46
48
  Or using named imports:
47
49
 
48
50
  ```typescript
49
- import { setApiKey } from 'upcrawl';
51
+ import { setApiKey } from '@upcrawl/sdk';
50
52
 
51
53
  setApiKey('uc-your-api-key');
52
54
  ```
@@ -54,7 +56,7 @@ setApiKey('uc-your-api-key');
54
56
  ### Scraping a Single URL
55
57
 
56
58
  ```typescript
57
- import Upcrawl from 'upcrawl';
59
+ import Upcrawl from '@upcrawl/sdk';
58
60
 
59
61
  Upcrawl.setApiKey('uc-your-api-key');
60
62
 
@@ -115,6 +117,37 @@ result.results.forEach(queryResult => {
115
117
  });
116
118
  ```
117
119
 
120
+ ### Generate PDF from HTML
121
+
122
+ Generate a PDF from HTML content:
123
+
124
+ ```typescript
125
+ const result = await Upcrawl.generatePdf({
126
+ html: '<html><body><h1>Invoice</h1><p>Total: $500</p></body></html>',
127
+ title: 'invoice-123',
128
+ pageSize: 'A4',
129
+ printBackground: true,
130
+ margin: { top: '20mm', right: '20mm', bottom: '20mm', left: '20mm' }
131
+ });
132
+
133
+ console.log(result.url); // Download URL for the PDF
134
+ ```
135
+
136
+ ### Generate PDF from URL
137
+
138
+ Generate a PDF from any webpage:
139
+
140
+ ```typescript
141
+ const result = await Upcrawl.generatePdfFromUrl({
142
+ url: 'https://example.com/report',
143
+ title: 'report',
144
+ pageSize: 'Letter',
145
+ landscape: true
146
+ });
147
+
148
+ console.log(result.url); // Download URL for the PDF
149
+ ```
150
+
118
151
  ### Domain Filtering
119
152
 
120
153
  Filter search results by domain:
@@ -182,7 +215,7 @@ Upcrawl.configure({
182
215
  The SDK throws `UpcrawlError` for API errors:
183
216
 
184
217
  ```typescript
185
- import Upcrawl, { UpcrawlError } from 'upcrawl';
218
+ import Upcrawl, { UpcrawlError } from '@upcrawl/sdk';
186
219
 
187
220
  try {
188
221
  const result = await Upcrawl.scrape({ url: 'https://example.com' });
@@ -214,8 +247,10 @@ import Upcrawl, {
214
247
  SearchOptions,
215
248
  SearchResponse,
216
249
  BatchScrapeOptions,
217
- BatchScrapeResponse
218
- } from 'upcrawl';
250
+ BatchScrapeResponse,
251
+ GeneratePdfOptions,
252
+ PdfResponse
253
+ } from '@upcrawl/sdk';
219
254
 
220
255
  const options: ScrapeOptions = {
221
256
  url: 'https://example.com',
@@ -238,6 +273,8 @@ const result: ScrapeResponse = await Upcrawl.scrape(options);
238
273
  | `Upcrawl.scrape(options)` | Scrape a single URL |
239
274
  | `Upcrawl.batchScrape(options)` | Scrape multiple URLs |
240
275
  | `Upcrawl.search(options)` | Search the web |
276
+ | `Upcrawl.generatePdf(options)` | Generate PDF from HTML |
277
+ | `Upcrawl.generatePdfFromUrl(options)` | Generate PDF from a URL |
241
278
 
242
279
  ### Scrape Options
243
280
 
@@ -261,6 +298,31 @@ const result: ScrapeResponse = await Upcrawl.scrape(options);
261
298
  | `includeDomains` | `string[]` | Only include these domains |
262
299
  | `excludeDomains` | `string[]` | Exclude these domains |
263
300
 
301
+ ### Generate PDF Options (from HTML)
302
+
303
+ | Option | Type | Description |
304
+ |--------|------|-------------|
305
+ | `html` | `string` | HTML content to convert (required) |
306
+ | `title` | `string` | Filename for the PDF |
307
+ | `pageSize` | `'A4' \| 'Letter' \| 'Legal'` | Page size (default: A4) |
308
+ | `landscape` | `boolean` | Landscape orientation |
309
+ | `margin` | `{ top?, right?, bottom?, left? }` | Page margins |
310
+ | `printBackground` | `boolean` | Print background graphics |
311
+ | `skipChartWait` | `boolean` | Skip chart rendering wait |
312
+ | `timeoutMs` | `number` | Timeout (5000-120000) |
313
+
314
+ ### Generate PDF Options (from URL)
315
+
316
+ | Option | Type | Description |
317
+ |--------|------|-------------|
318
+ | `url` | `string` | URL to convert (required) |
319
+ | `title` | `string` | Filename for the PDF |
320
+ | `pageSize` | `'A4' \| 'Letter' \| 'Legal'` | Page size (default: A4) |
321
+ | `landscape` | `boolean` | Landscape orientation |
322
+ | `margin` | `{ top?, right?, bottom?, left? }` | Page margins |
323
+ | `printBackground` | `boolean` | Print background graphics |
324
+ | `timeoutMs` | `number` | Timeout (5000-120000) |
325
+
264
326
  ## License
265
327
 
266
328
  MIT
package/dist/index.d.mts CHANGED
@@ -141,6 +141,60 @@ interface SearchResponse {
141
141
  /** Total cost in USD */
142
142
  cost?: number;
143
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
+ }
144
198
  interface UpcrawlErrorResponse {
145
199
  error: {
146
200
  code: string;
@@ -196,7 +250,7 @@ declare function resetConfig(): void;
196
250
  *
197
251
  * @example
198
252
  * ```typescript
199
- * import { scrape, setApiKey } from 'upcrawl';
253
+ * import { scrape, setApiKey } from '@upcrawl/sdk';
200
254
  *
201
255
  * setApiKey('uc-your-api-key');
202
256
  *
@@ -217,7 +271,7 @@ declare function scrape(options: ScrapeOptions): Promise<ScrapeResponse>;
217
271
  *
218
272
  * @example
219
273
  * ```typescript
220
- * import { batchScrape, setApiKey } from 'upcrawl';
274
+ * import { batchScrape, setApiKey } from '@upcrawl/sdk';
221
275
  *
222
276
  * setApiKey('uc-your-api-key');
223
277
  *
@@ -241,7 +295,7 @@ declare function batchScrape(options: BatchScrapeOptions): Promise<BatchScrapeRe
241
295
  *
242
296
  * @example
243
297
  * ```typescript
244
- * import { search, setApiKey } from 'upcrawl';
298
+ * import { search, setApiKey } from '@upcrawl/sdk';
245
299
  *
246
300
  * setApiKey('uc-your-api-key');
247
301
  *
@@ -260,6 +314,49 @@ declare function batchScrape(options: BatchScrapeOptions): Promise<BatchScrapeRe
260
314
  * ```
261
315
  */
262
316
  declare function search(options: SearchOptions): Promise<SearchResponse>;
317
+ /**
318
+ * Generate a PDF from HTML content
319
+ * @param options - PDF options including the HTML content
320
+ * @returns Promise with PDF response containing the download URL
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * import Upcrawl from '@upcrawl/sdk';
325
+ *
326
+ * Upcrawl.setApiKey('uc-your-api-key');
327
+ *
328
+ * const result = await Upcrawl.generatePdf({
329
+ * html: '<html><body><h1>Hello World</h1></body></html>',
330
+ * title: 'my-document',
331
+ * pageSize: 'A4'
332
+ * });
333
+ *
334
+ * console.log(result.url); // URL to download the PDF
335
+ * ```
336
+ */
337
+ declare function generatePdf(options: GeneratePdfOptions): Promise<PdfResponse>;
338
+ /**
339
+ * Generate a PDF from a URL
340
+ * @param options - PDF options including the URL to convert
341
+ * @returns Promise with PDF response containing the download URL
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * import Upcrawl from '@upcrawl/sdk';
346
+ *
347
+ * Upcrawl.setApiKey('uc-your-api-key');
348
+ *
349
+ * const result = await Upcrawl.generatePdfFromUrl({
350
+ * url: 'https://example.com',
351
+ * title: 'example-page',
352
+ * pageSize: 'Letter',
353
+ * landscape: true
354
+ * });
355
+ *
356
+ * console.log(result.url); // URL to download the PDF
357
+ * ```
358
+ */
359
+ declare function generatePdfFromUrl(options: GeneratePdfFromUrlOptions): Promise<PdfResponse>;
263
360
 
264
361
  /**
265
362
  * Upcrawl SDK
@@ -268,7 +365,7 @@ declare function search(options: SearchOptions): Promise<SearchResponse>;
268
365
  * @example
269
366
  * ```typescript
270
367
  * // Using the Upcrawl namespace (recommended)
271
- * import Upcrawl from 'upcrawl';
368
+ * import Upcrawl from '@upcrawl/sdk';
272
369
  *
273
370
  * Upcrawl.setApiKey('uc-your-api-key');
274
371
  *
@@ -281,7 +378,7 @@ declare function search(options: SearchOptions): Promise<SearchResponse>;
281
378
  * @example
282
379
  * ```typescript
283
380
  * // Using named imports
284
- * import { setApiKey, scrape, search } from 'upcrawl';
381
+ * import { setApiKey, scrape, search } from '@upcrawl/sdk';
285
382
  *
286
383
  * setApiKey('uc-your-api-key');
287
384
  *
@@ -295,7 +392,7 @@ declare function search(options: SearchOptions): Promise<SearchResponse>;
295
392
  *
296
393
  * @example
297
394
  * ```typescript
298
- * import Upcrawl from 'upcrawl';
395
+ * import Upcrawl from '@upcrawl/sdk';
299
396
  *
300
397
  * // Set API key globally
301
398
  * Upcrawl.setApiKey('uc-your-api-key');
@@ -364,10 +461,22 @@ declare const Upcrawl: {
364
461
  * @returns Promise with search response
365
462
  */
366
463
  readonly search: typeof search;
464
+ /**
465
+ * Generate a PDF from HTML content
466
+ * @param options - PDF options including the HTML content
467
+ * @returns Promise with PDF response containing the download URL
468
+ */
469
+ readonly generatePdf: typeof generatePdf;
470
+ /**
471
+ * Generate a PDF from a URL
472
+ * @param options - PDF options including the URL to convert
473
+ * @returns Promise with PDF response containing the download URL
474
+ */
475
+ readonly generatePdfFromUrl: typeof generatePdfFromUrl;
367
476
  /**
368
477
  * Error class for Upcrawl API errors
369
478
  */
370
479
  readonly UpcrawlError: typeof UpcrawlError;
371
480
  };
372
481
 
373
- export { type BatchScrapeOptions, type BatchScrapeResponse, 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, getConfig, resetConfig, scrape, search, setApiKey, setBaseUrl, setTimeout };
482
+ export { type BatchScrapeOptions, type BatchScrapeResponse, 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, generatePdf, generatePdfFromUrl, getConfig, resetConfig, scrape, search, setApiKey, setBaseUrl, setTimeout };
package/dist/index.d.ts CHANGED
@@ -141,6 +141,60 @@ interface SearchResponse {
141
141
  /** Total cost in USD */
142
142
  cost?: number;
143
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
+ }
144
198
  interface UpcrawlErrorResponse {
145
199
  error: {
146
200
  code: string;
@@ -196,7 +250,7 @@ declare function resetConfig(): void;
196
250
  *
197
251
  * @example
198
252
  * ```typescript
199
- * import { scrape, setApiKey } from 'upcrawl';
253
+ * import { scrape, setApiKey } from '@upcrawl/sdk';
200
254
  *
201
255
  * setApiKey('uc-your-api-key');
202
256
  *
@@ -217,7 +271,7 @@ declare function scrape(options: ScrapeOptions): Promise<ScrapeResponse>;
217
271
  *
218
272
  * @example
219
273
  * ```typescript
220
- * import { batchScrape, setApiKey } from 'upcrawl';
274
+ * import { batchScrape, setApiKey } from '@upcrawl/sdk';
221
275
  *
222
276
  * setApiKey('uc-your-api-key');
223
277
  *
@@ -241,7 +295,7 @@ declare function batchScrape(options: BatchScrapeOptions): Promise<BatchScrapeRe
241
295
  *
242
296
  * @example
243
297
  * ```typescript
244
- * import { search, setApiKey } from 'upcrawl';
298
+ * import { search, setApiKey } from '@upcrawl/sdk';
245
299
  *
246
300
  * setApiKey('uc-your-api-key');
247
301
  *
@@ -260,6 +314,49 @@ declare function batchScrape(options: BatchScrapeOptions): Promise<BatchScrapeRe
260
314
  * ```
261
315
  */
262
316
  declare function search(options: SearchOptions): Promise<SearchResponse>;
317
+ /**
318
+ * Generate a PDF from HTML content
319
+ * @param options - PDF options including the HTML content
320
+ * @returns Promise with PDF response containing the download URL
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * import Upcrawl from '@upcrawl/sdk';
325
+ *
326
+ * Upcrawl.setApiKey('uc-your-api-key');
327
+ *
328
+ * const result = await Upcrawl.generatePdf({
329
+ * html: '<html><body><h1>Hello World</h1></body></html>',
330
+ * title: 'my-document',
331
+ * pageSize: 'A4'
332
+ * });
333
+ *
334
+ * console.log(result.url); // URL to download the PDF
335
+ * ```
336
+ */
337
+ declare function generatePdf(options: GeneratePdfOptions): Promise<PdfResponse>;
338
+ /**
339
+ * Generate a PDF from a URL
340
+ * @param options - PDF options including the URL to convert
341
+ * @returns Promise with PDF response containing the download URL
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * import Upcrawl from '@upcrawl/sdk';
346
+ *
347
+ * Upcrawl.setApiKey('uc-your-api-key');
348
+ *
349
+ * const result = await Upcrawl.generatePdfFromUrl({
350
+ * url: 'https://example.com',
351
+ * title: 'example-page',
352
+ * pageSize: 'Letter',
353
+ * landscape: true
354
+ * });
355
+ *
356
+ * console.log(result.url); // URL to download the PDF
357
+ * ```
358
+ */
359
+ declare function generatePdfFromUrl(options: GeneratePdfFromUrlOptions): Promise<PdfResponse>;
263
360
 
264
361
  /**
265
362
  * Upcrawl SDK
@@ -268,7 +365,7 @@ declare function search(options: SearchOptions): Promise<SearchResponse>;
268
365
  * @example
269
366
  * ```typescript
270
367
  * // Using the Upcrawl namespace (recommended)
271
- * import Upcrawl from 'upcrawl';
368
+ * import Upcrawl from '@upcrawl/sdk';
272
369
  *
273
370
  * Upcrawl.setApiKey('uc-your-api-key');
274
371
  *
@@ -281,7 +378,7 @@ declare function search(options: SearchOptions): Promise<SearchResponse>;
281
378
  * @example
282
379
  * ```typescript
283
380
  * // Using named imports
284
- * import { setApiKey, scrape, search } from 'upcrawl';
381
+ * import { setApiKey, scrape, search } from '@upcrawl/sdk';
285
382
  *
286
383
  * setApiKey('uc-your-api-key');
287
384
  *
@@ -295,7 +392,7 @@ declare function search(options: SearchOptions): Promise<SearchResponse>;
295
392
  *
296
393
  * @example
297
394
  * ```typescript
298
- * import Upcrawl from 'upcrawl';
395
+ * import Upcrawl from '@upcrawl/sdk';
299
396
  *
300
397
  * // Set API key globally
301
398
  * Upcrawl.setApiKey('uc-your-api-key');
@@ -364,10 +461,22 @@ declare const Upcrawl: {
364
461
  * @returns Promise with search response
365
462
  */
366
463
  readonly search: typeof search;
464
+ /**
465
+ * Generate a PDF from HTML content
466
+ * @param options - PDF options including the HTML content
467
+ * @returns Promise with PDF response containing the download URL
468
+ */
469
+ readonly generatePdf: typeof generatePdf;
470
+ /**
471
+ * Generate a PDF from a URL
472
+ * @param options - PDF options including the URL to convert
473
+ * @returns Promise with PDF response containing the download URL
474
+ */
475
+ readonly generatePdfFromUrl: typeof generatePdfFromUrl;
367
476
  /**
368
477
  * Error class for Upcrawl API errors
369
478
  */
370
479
  readonly UpcrawlError: typeof UpcrawlError;
371
480
  };
372
481
 
373
- export { type BatchScrapeOptions, type BatchScrapeResponse, 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, getConfig, resetConfig, scrape, search, setApiKey, setBaseUrl, setTimeout };
482
+ export { type BatchScrapeOptions, type BatchScrapeResponse, 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, generatePdf, generatePdfFromUrl, getConfig, resetConfig, scrape, search, setApiKey, setBaseUrl, setTimeout };
package/dist/index.js CHANGED
@@ -34,6 +34,8 @@ __export(index_exports, {
34
34
  batchScrape: () => batchScrape,
35
35
  configure: () => configure,
36
36
  default: () => index_default,
37
+ generatePdf: () => generatePdf,
38
+ generatePdfFromUrl: () => generatePdfFromUrl,
37
39
  getConfig: () => getConfig,
38
40
  resetConfig: () => resetConfig,
39
41
  scrape: () => scrape,
@@ -182,6 +184,24 @@ async function search(options) {
182
184
  handleError(error);
183
185
  }
184
186
  }
187
+ async function generatePdf(options) {
188
+ try {
189
+ const client = createClient();
190
+ const response = await client.post("/pdf/html", options);
191
+ return response.data;
192
+ } catch (error) {
193
+ handleError(error);
194
+ }
195
+ }
196
+ async function generatePdfFromUrl(options) {
197
+ try {
198
+ const client = createClient();
199
+ const response = await client.post("/pdf/url", options);
200
+ return response.data;
201
+ } catch (error) {
202
+ handleError(error);
203
+ }
204
+ }
185
205
 
186
206
  // src/index.ts
187
207
  var Upcrawl = {
@@ -231,6 +251,18 @@ var Upcrawl = {
231
251
  * @returns Promise with search response
232
252
  */
233
253
  search,
254
+ /**
255
+ * Generate a PDF from HTML content
256
+ * @param options - PDF options including the HTML content
257
+ * @returns Promise with PDF response containing the download URL
258
+ */
259
+ generatePdf,
260
+ /**
261
+ * Generate a PDF from a URL
262
+ * @param options - PDF options including the URL to convert
263
+ * @returns Promise with PDF response containing the download URL
264
+ */
265
+ generatePdfFromUrl,
234
266
  /**
235
267
  * Error class for Upcrawl API errors
236
268
  */
@@ -242,6 +274,8 @@ var index_default = Upcrawl;
242
274
  UpcrawlError,
243
275
  batchScrape,
244
276
  configure,
277
+ generatePdf,
278
+ generatePdfFromUrl,
245
279
  getConfig,
246
280
  resetConfig,
247
281
  scrape,
package/dist/index.mjs CHANGED
@@ -136,6 +136,24 @@ async function search(options) {
136
136
  handleError(error);
137
137
  }
138
138
  }
139
+ async function generatePdf(options) {
140
+ try {
141
+ const client = createClient();
142
+ const response = await client.post("/pdf/html", options);
143
+ return response.data;
144
+ } catch (error) {
145
+ handleError(error);
146
+ }
147
+ }
148
+ async function generatePdfFromUrl(options) {
149
+ try {
150
+ const client = createClient();
151
+ const response = await client.post("/pdf/url", options);
152
+ return response.data;
153
+ } catch (error) {
154
+ handleError(error);
155
+ }
156
+ }
139
157
 
140
158
  // src/index.ts
141
159
  var Upcrawl = {
@@ -185,6 +203,18 @@ var Upcrawl = {
185
203
  * @returns Promise with search response
186
204
  */
187
205
  search,
206
+ /**
207
+ * Generate a PDF from HTML content
208
+ * @param options - PDF options including the HTML content
209
+ * @returns Promise with PDF response containing the download URL
210
+ */
211
+ generatePdf,
212
+ /**
213
+ * Generate a PDF from a URL
214
+ * @param options - PDF options including the URL to convert
215
+ * @returns Promise with PDF response containing the download URL
216
+ */
217
+ generatePdfFromUrl,
188
218
  /**
189
219
  * Error class for Upcrawl API errors
190
220
  */
@@ -196,6 +226,8 @@ export {
196
226
  batchScrape,
197
227
  configure,
198
228
  index_default as default,
229
+ generatePdf,
230
+ generatePdfFromUrl,
199
231
  getConfig,
200
232
  resetConfig,
201
233
  scrape,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upcrawl/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },