1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "document": "https://files.manuscdn.com/user_upload_by_module/session_file/310519663080398616/ATUpqEGiovUnQJOt.txt",
12 "outputSchema": {
13 "type": "object",
14 "properties": {
15 "invoiceNumber": {
16 "type": [
17 "string",
18 "null"
19 ],
20 "description": "Invoice identifier exactly as printed"
21 },
22 "invoiceDate": {
23 "type": [
24 "string",
25 "null"
26 ],
27 "description": "Invoice date in YYYY-MM-DD format"
28 },
29 "currency": {
30 "type": [
31 "string",
32 "null"
33 ],
34 "description": "Three-letter ISO currency code"
35 },
36 "supplierName": {
37 "type": [
38 "string",
39 "null"
40 ]
41 },
42 "supplierVatId": {
43 "type": [
44 "string",
45 "null"
46 ]
47 },
48 "customerName": {
49 "type": [
50 "string",
51 "null"
52 ]
53 },
54 "subtotal": {
55 "type": [
56 "number",
57 "null"
58 ]
59 },
60 "tax": {
61 "type": [
62 "number",
63 "null"
64 ]
65 },
66 "total": {
67 "type": [
68 "number",
69 "null"
70 ]
71 },
72 "dueDate": {
73 "type": [
74 "string",
75 "null"
76 ],
77 "description": "Payment due date in YYYY-MM-DD format"
78 }
79 },
80 "required": [
81 "invoiceNumber",
82 "invoiceDate",
83 "currency",
84 "supplierName",
85 "supplierVatId",
86 "customerName",
87 "subtotal",
88 "tax",
89 "total",
90 "dueDate"
91 ],
92 "additionalProperties": false
93 }
94};
95
96
97const run = await client.actor("scalogik/document-processing-api-pdf-ocr-validated-json").call(input);
98
99
100console.log('Results from dataset');
101console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
102const { items } = await client.dataset(run.defaultDatasetId).listItems();
103items.forEach((item) => {
104 console.dir(item);
105});
106
107