1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "documents": [
12 {
13 "url": "https://example.com/invoice.pdf",
14 "filename": "invoice.pdf"
15 }
16 ],
17 "fields": [
18 {
19 "name": "invoice_number",
20 "description": "The unique invoice identifier",
21 "type": "string"
22 },
23 {
24 "name": "invoice_date",
25 "description": "The invoice issue date",
26 "type": "date"
27 },
28 {
29 "name": "supplier_name",
30 "description": "The legal name of the supplier",
31 "type": "string"
32 },
33 {
34 "name": "total_amount",
35 "description": "The final amount including taxes",
36 "type": "number"
37 }
38 ]
39};
40
41
42const run = await client.actor("obaskly/ai-data-extraction-api").call(input);
43
44
45console.log('Results from dataset');
46console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
47const { items } = await client.dataset(run.defaultDatasetId).listItems();
48items.forEach((item) => {
49 console.dir(item);
50});
51
52