1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "mode": "analyze",
12 "sample": "english-services-agreement",
13 "schema": {
14 "type": "object",
15 "properties": {
16 "effective_date": {
17 "type": "string",
18 "format": "date",
19 "description": "the date the agreement takes effect"
20 },
21 "annual_fee": {
22 "type": "number",
23 "description": "the fixed annual fee payable by the client"
24 },
25 "notice_period_days": {
26 "type": "integer",
27 "description": "days of written notice required for non renewal",
28 "x-keywords": [
29 "notice of non-renewal"
30 ]
31 },
32 "governing_law": {
33 "type": "string",
34 "description": "the law governing the agreement",
35 "x-keywords": [
36 "governed by"
37 ]
38 }
39 },
40 "required": [
41 "effective_date"
42 ]
43 },
44 "ocr": true,
45 "ocrLanguages": [
46 "eng",
47 "ara"
48 ]
49};
50
51
52const run = await client.actor("omargnagy/document-to-json-extractor").call(input);
53
54
55console.log('Results from dataset');
56console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
57const { items } = await client.dataset(run.defaultDatasetId).listItems();
58items.forEach((item) => {
59 console.dir(item);
60});
61
62