@upcrawl/sdk 1.0.0 → 1.2.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
@@ -1,23 +1,23 @@
1
- # Upcrawl
1
+ # @upcrawl/sdk
2
2
 
3
3
  Official Node.js/Browser SDK for the [Upcrawl](https://upcrawl.dev) API. Extract data from any website with a single API call.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install upcrawl
8
+ npm install @upcrawl/sdk
9
9
  ```
10
10
 
11
11
  Or with yarn:
12
12
 
13
13
  ```bash
14
- yarn add upcrawl
14
+ yarn add @upcrawl/sdk
15
15
  ```
16
16
 
17
17
  ## Quick Start
18
18
 
19
19
  ```typescript
20
- import Upcrawl from 'upcrawl';
20
+ import Upcrawl from '@upcrawl/sdk';
21
21
 
22
22
  // Set your API key (get one at https://upcrawl.dev)
23
23
  Upcrawl.setApiKey('uc-your-api-key');
@@ -38,7 +38,7 @@ console.log(result.markdown);
38
38
  The API key must be set before making any requests:
39
39
 
40
40
  ```typescript
41
- import Upcrawl from 'upcrawl';
41
+ import Upcrawl from '@upcrawl/sdk';
42
42
 
43
43
  Upcrawl.setApiKey('uc-your-api-key');
44
44
  ```
@@ -46,7 +46,7 @@ Upcrawl.setApiKey('uc-your-api-key');
46
46
  Or using named imports:
47
47
 
48
48
  ```typescript
49
- import { setApiKey } from 'upcrawl';
49
+ import { setApiKey } from '@upcrawl/sdk';
50
50
 
51
51
  setApiKey('uc-your-api-key');
52
52
  ```
@@ -54,7 +54,7 @@ setApiKey('uc-your-api-key');
54
54
  ### Scraping a Single URL
55
55
 
56
56
  ```typescript
57
- import Upcrawl from 'upcrawl';
57
+ import Upcrawl from '@upcrawl/sdk';
58
58
 
59
59
  Upcrawl.setApiKey('uc-your-api-key');
60
60
 
@@ -115,6 +115,37 @@ result.results.forEach(queryResult => {
115
115
  });
116
116
  ```
117
117
 
118
+ ### Generate PDF from HTML
119
+
120
+ Generate a PDF from HTML content:
121
+
122
+ ```typescript
123
+ const result = await Upcrawl.generatePdf({
124
+ html: '<html><body><h1>Invoice</h1><p>Total: $500</p></body></html>',
125
+ title: 'invoice-123',
126
+ pageSize: 'A4',
127
+ printBackground: true,
128
+ margin: { top: '20mm', right: '20mm', bottom: '20mm', left: '20mm' }
129
+ });
130
+
131
+ console.log(result.url); // Download URL for the PDF
132
+ ```
133
+
134
+ ### Generate PDF from URL
135
+
136
+ Generate a PDF from any webpage:
137
+
138
+ ```typescript
139
+ const result = await Upcrawl.generatePdfFromUrl({
140
+ url: 'https://example.com/report',
141
+ title: 'report',
142
+ pageSize: 'Letter',
143
+ landscape: true
144
+ });
145
+
146
+ console.log(result.url); // Download URL for the PDF
147
+ ```
148
+
118
149
  ### Domain Filtering
119
150
 
120
151
  Filter search results by domain:
@@ -182,7 +213,7 @@ Upcrawl.configure({
182
213
  The SDK throws `UpcrawlError` for API errors:
183
214
 
184
215
  ```typescript
185
- import Upcrawl, { UpcrawlError } from 'upcrawl';
216
+ import Upcrawl, { UpcrawlError } from '@upcrawl/sdk';
186
217
 
187
218
  try {
188
219
  const result = await Upcrawl.scrape({ url: 'https://example.com' });
@@ -214,8 +245,10 @@ import Upcrawl, {
214
245
  SearchOptions,
215
246
  SearchResponse,
216
247
  BatchScrapeOptions,
217
- BatchScrapeResponse
218
- } from 'upcrawl';
248
+ BatchScrapeResponse,
249
+ GeneratePdfOptions,
250
+ PdfResponse
251
+ } from '@upcrawl/sdk';
219
252
 
220
253
  const options: ScrapeOptions = {
221
254
  url: 'https://example.com',
@@ -238,6 +271,8 @@ const result: ScrapeResponse = await Upcrawl.scrape(options);
238
271
  | `Upcrawl.scrape(options)` | Scrape a single URL |
239
272
  | `Upcrawl.batchScrape(options)` | Scrape multiple URLs |
240
273
  | `Upcrawl.search(options)` | Search the web |
274
+ | `Upcrawl.generatePdf(options)` | Generate PDF from HTML |
275
+ | `Upcrawl.generatePdfFromUrl(options)` | Generate PDF from a URL |
241
276
 
242
277
  ### Scrape Options
243
278
 
@@ -261,6 +296,31 @@ const result: ScrapeResponse = await Upcrawl.scrape(options);
261
296
  | `includeDomains` | `string[]` | Only include these domains |
262
297
  | `excludeDomains` | `string[]` | Exclude these domains |
263
298
 
299
+ ### Generate PDF Options (from HTML)
300
+
301
+ | Option | Type | Description |
302
+ |--------|------|-------------|
303
+ | `html` | `string` | HTML content to convert (required) |
304
+ | `title` | `string` | Filename for the PDF |
305
+ | `pageSize` | `'A4' \| 'Letter' \| 'Legal'` | Page size (default: A4) |
306
+ | `landscape` | `boolean` | Landscape orientation |
307
+ | `margin` | `{ top?, right?, bottom?, left? }` | Page margins |
308
+ | `printBackground` | `boolean` | Print background graphics |
309
+ | `skipChartWait` | `boolean` | Skip chart rendering wait |
310
+ | `timeoutMs` | `number` | Timeout (5000-120000) |
311
+
312
+ ### Generate PDF Options (from URL)
313
+
314
+ | Option | Type | Description |
315
+ |--------|------|-------------|
316
+ | `url` | `string` | URL to convert (required) |
317
+ | `title` | `string` | Filename for the PDF |
318
+ | `pageSize` | `'A4' \| 'Letter' \| 'Legal'` | Page size (default: A4) |
319
+ | `landscape` | `boolean` | Landscape orientation |
320
+ | `margin` | `{ top?, right?, bottom?, left? }` | Page margins |
321
+ | `printBackground` | `boolean` | Print background graphics |
322
+ | `timeoutMs` | `number` | Timeout (5000-120000) |
323
+
264
324
  ## License
265
325
 
266
326
  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.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },