1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "mode": "inline",
10 "documents": [{
11 "id": "invoice-1001",
12 "contentType": "text/plain",
13 "fileName": "invoice-1001.txt",
14 "text": """Invoice Number: INV-1001
15Invoice Date: 2026-09-20
16Supplier: Northwind Parts Ltd
17Total Due: 1240.50
18Currency: GBP""",
19 }],
20 "jsonSchema": {
21 "type": "object",
22 "additionalProperties": False,
23 "required": [
24 "invoiceNumber",
25 "invoiceDate",
26 "supplier",
27 "totalDue",
28 "currency",
29 ],
30 "properties": {
31 "currency": {
32 "type": "string",
33 "enum": [
34 "GBP",
35 "EUR",
36 "USD",
37 ],
38 },
39 "invoiceDate": {
40 "type": "string",
41 "format": "date",
42 },
43 "invoiceNumber": { "type": "string" },
44 "supplier": { "type": "string" },
45 "totalDue": {
46 "type": "number",
47 "minimum": 0,
48 },
49 },
50 },
51 "fieldConfig": {
52 "invoiceNumber": {
53 "aliases": [
54 "Invoice Number",
55 "Invoice No",
56 ],
57 "description": "Unique invoice identifier",
58 },
59 "totalDue": {
60 "aliases": [
61 "Total Due",
62 "Amount Due",
63 ],
64 "description": "Final amount payable",
65 },
66 },
67}
68
69
70run = client.actor("first_watch/pdf-document-structured-json-extraction").call(run_input=run_input)
71
72
73print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
74for item in client.dataset(run.default_dataset_id).iterate_items():
75 print(item)
76
77