1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "documentUrls": [],
12 "targetSchema": {
13 "type": "object",
14 "properties": {
15 "invoiceNumber": {
16 "type": "string",
17 "title": "Invoice Number"
18 },
19 "totalAmount": {
20 "type": "number",
21 "title": "Total Amount"
22 },
23 "lineItems": {
24 "type": "array",
25 "title": "Line Items",
26 "items": {
27 "type": "object",
28 "properties": {
29 "description": {
30 "type": "string",
31 "title": "Description"
32 },
33 "quantity": {
34 "type": "integer",
35 "title": "Quantity"
36 },
37 "unitPrice": {
38 "type": "number",
39 "title": "Unit Price"
40 }
41 }
42 }
43 }
44 }
45 }
46};
47
48
49const run = await client.actor("thomas.5fm/pdf-to-json-schema-extractor").call(input);
50
51
52console.log('Results from dataset');
53console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
54const { items } = await client.dataset(run.defaultDatasetId).listItems();
55items.forEach((item) => {
56 console.dir(item);
57});
58
59