1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "urls": [
12 "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
13 ],
14 "schema": {
15 "type": "object",
16 "properties": {
17 "title": {
18 "type": "string",
19 "description": "Title of the form"
20 },
21 "formNumber": {
22 "type": "string",
23 "description": "The form number, e.g. W-9 or 1040"
24 },
25 "revisionDate": {
26 "type": "string",
27 "format": "date",
28 "description": "Revision date of the form"
29 },
30 "issuer": {
31 "type": "string",
32 "description": "Agency or organization that issues the form"
33 },
34 "fields": {
35 "type": "array",
36 "description": "The numbered fields a filer completes",
37 "items": {
38 "type": "object",
39 "properties": {
40 "label": {
41 "type": "string"
42 },
43 "description": {
44 "type": "string"
45 }
46 }
47 }
48 }
49 }
50 },
51 "extractor": "rules",
52 "includeMarkdown": false
53};
54
55
56const run = await client.actor("owlabee/document-to-json-extractor").call(input);
57
58
59console.log('Results from dataset');
60console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
61const { items } = await client.dataset(run.defaultDatasetId).listItems();
62items.forEach((item) => {
63 console.dir(item);
64});
65
66