structocr 1.7.0__tar.gz → 1.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.4
2
+ Name: structocr
3
+ Version: 1.8.0
4
+ Summary: Structured OCR API SDK for Python: passports, visas, proof of address, health cards, IDs, driver licenses, auto insurance, VIN Pro, invoices, receipts, and bills of lading.
5
+ Home-page: https://structocr.com
6
+ Author: StructOCR Team
7
+ Author-email: support@structocr.com
8
+ License: MIT
9
+ Project-URL: Homepage, https://structocr.com
10
+ Project-URL: Documentation, https://structocr.com/developers
11
+ Project-URL: Get a free API key, https://structocr.com/register?utm_source=pypi&utm_medium=project_urls&utm_campaign=sdk
12
+ Project-URL: Source, https://github.com/dracula911/structocr-python
13
+ Project-URL: Tracker, https://github.com/dracula911/structocr-python/issues
14
+ Keywords: ocr,passport ocr,mrz,id card ocr,driver license ocr,pdf417,health card ocr,proof of address ocr,visa ocr,vin ocr,vin pro ocr,auto insurance ocr,invoice ocr,receipt ocr,bill of lading ocr,freight ocr,kyc,document ai,structocr
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
19
+ Requires-Python: >=3.7
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests>=2.25.0
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: keywords
30
+ Dynamic: license
31
+ Dynamic: license-file
32
+ Dynamic: project-url
33
+ Dynamic: requires-dist
34
+ Dynamic: requires-python
35
+ Dynamic: summary
36
+
37
+ # StructOCR Python SDK
38
+
39
+ Official Python client for the [StructOCR API](https://structocr.com/developers?utm_source=pypi&utm_medium=readme&utm_campaign=sdk).
40
+
41
+ Extract validated, structured JSON from 19 document types — spanning identity & KYC (passports, travel visas, proof of address, national IDs, driver licenses, PDF417 barcodes, health insurance cards), vehicles & insurance (VIN, VIN Pro vehicle decode, license plates, registrations, auto insurance cards), finance (invoices, receipts), and logistics (bills of lading, shipping containers, weighbridge tickets, ATM cassettes, boat HINs). One method call per document, zero template training.
42
+
43
+ The SDK accepts a local JPG, PNG, WebP, or PDF path, plus in-memory `bytes`. It validates the decoded file locally, converts it to Base64, and sends JSON as `{"img": "..."}`. The REST API also supports multipart uploads; this SDK release keeps Base64 JSON as its default transport for backward compatibility.
44
+
45
+ ## Get a free API key
46
+
47
+ 1. [Create an account](https://structocr.com/register?utm_source=pypi&utm_medium=readme&utm_campaign=sdk). New accounts get **200 free credits**, enough for 100 two-credit document scans, and no credit card is needed.
48
+ 2. Copy your key from **API Keys** in the dashboard.
49
+ 3. Optionally test any of the 19 endpoints on a sample image in the [Playground](https://structocr.com/dashboard/playground?utm_source=pypi&utm_medium=readme&utm_campaign=sdk) before you write code.
50
+
51
+ Not ready to sign up? Try documents directly in your browser on a sample image or your own file, no account needed: use the **Try it** links in the table below.
52
+
53
+ After the free credits, packs start at $5 for 500 credits. There is no subscription and credits do not expire. See [pricing](https://structocr.com/pricing?utm_source=pypi&utm_medium=readme&utm_campaign=sdk).
54
+
55
+ ## Supported documents
56
+
57
+ | Document | Method | Credits per scan | Try it |
58
+ | --- | --- | --- | --- |
59
+ | Passport | `scan_passport` | 2 | [Try it](https://structocr.com/products/passport-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
60
+ | Driver license (front) | `scan_driver_license` | 2 | [Try it](https://structocr.com/products/driver-license-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
61
+ | US/Canada driver license PDF417 barcode | `scan_driver_license_pdf417` | 2 | [Try it](https://structocr.com/tools/driver-license-pdf417-scanner?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try) |
62
+ | National ID card | `scan_national_id` | 2 | [Try it](https://structocr.com/products/national-id-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
63
+ | Health insurance card *(New)* | `scan_health_card` | 2 | [Try it](https://structocr.com/products/health-card-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
64
+ | Proof of Address *(New)* | `scan_proof_of_address` | 2 | [Try it](https://structocr.com/products/proof-of-address-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
65
+ | Travel visa (MRV-A/B & eVisa) *(New)* | `scan_visa` | 2 | [Try it](https://structocr.com/products/visa-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
66
+ | VIN | `scan_vin` | 1 | [Try it](https://structocr.com/products/vin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
67
+ | VIN Pro (VIN + vehicle details) *(New)* | `scan_vin_pro` | 2 | |
68
+ | License plate | `scan_license_plate` | 1 | [Try it](https://structocr.com/products/license-plate-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
69
+ | Vehicle registration | `scan_vehicle_registration` | 2 | [Try it](https://structocr.com/products/vehicle-registration-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
70
+ | Auto insurance card *(New)* | `scan_auto_insurance` | 2 | [Try it](https://structocr.com/products/auto-insurance-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
71
+ | Invoice | `scan_invoice` | 3 | [Try it](https://structocr.com/products/invoice-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
72
+ | Receipt | `scan_receipt` | 1 | [Try it](https://structocr.com/products/receipt-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
73
+ | Shipping container (ISO 6346) | `scan_container` | 1 | [Try it](https://structocr.com/products/container-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
74
+ | Bill of Lading & freight *(New)* | `scan_bill_of_lading` | 3 | [Try it](https://structocr.com/products/bill-of-lading-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
75
+ | Weighbridge ticket | `scan_weighbridge_ticket` | 2 | [Try it](https://structocr.com/products/weighbridge-ticket-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
76
+ | ATM cassette | `scan_atm_cassette` | 1 | |
77
+ | HIN (boat hull number) | `scan_hin` | 1 | [Try it](https://structocr.com/products/hin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
78
+
79
+ The receipt endpoint's optional enhanced mode costs 2 credits. Only successful requests are charged.
80
+
81
+ ## What's new in v1.8.0
82
+
83
+ Added native SDK methods for all six newly launched StructOCR endpoints:
84
+
85
+ - **`scan_proof_of_address(file)`** (`POST /v1/proof-of-address`, 2 credits) — Utility bills, bank statements, tax notices, and leases with 90/180-day freshness and PO Box checks.
86
+ - **`scan_visa(file)`** (`POST /v1/visa`, 2 credits) — Passport visa stickers (ICAO 9303 MRV-A 2×44 & MRV-B 2×36 check-digit verification) and global eVisa PDFs.
87
+ - **`scan_bill_of_lading(file)`** (`POST /v1/bill-of-lading`, 3 credits) — Ocean/road Bills of Lading, Packing Lists, Air Waybills (IATA Mod-7 validation), Commercial Invoices, and signed PODs with ISO 6346 container checks and cargo weight reconciliation.
88
+ - **`scan_health_card(file)`** (`POST /v1/health-card`, 2 credits) — US health insurance cards (Member ID, Group, RxBIN/RxPCN/RxGRP, copays), GCC/Canada/India/Brazil medical cards, and EU Tessera Sanitaria/EHIC, including 2-page front+back PDFs.
89
+ - **`scan_auto_insurance(file)`** (`POST /v1/auto-insurance`, 2 credits) — US ACORD 50 / state proof of insurance and Canadian Pink Cards with NAIC, policy date, and VIN check-digit validation.
90
+ - **`scan_vin_pro(file)`** (`POST /v1/vin-pro`, 2 credits) — VIN OCR with ISO 3779 check-digit validation plus decoded vehicle year, make, model, trim, engine, and body class.
91
+
92
+ ## Install
93
+
94
+ ```bash
95
+ pip install --upgrade structocr
96
+ ```
97
+
98
+ Python 3.7+ is required.
99
+
100
+ ## Quick start
101
+
102
+ ```bash
103
+ export STRUCTOCR_API_KEY="YOUR_API_KEY"
104
+ ```
105
+
106
+ ```python
107
+ from structocr import StructOCR
108
+
109
+ client = StructOCR()
110
+ result = client.scan_passport("./passport.jpg")
111
+
112
+ if result.get("success"):
113
+ data = result["data"]
114
+ print(data.get("passport_number"))
115
+ print(data.get("given_names"), data.get("surname"))
116
+ ```
117
+
118
+ A passport scan returns JSON like this (fictional sample document):
119
+
120
+ ```json
121
+ {
122
+ "success": true,
123
+ "data": {
124
+ "type": "passport",
125
+ "country_code": "UTO",
126
+ "nationality": "UTOPIAN",
127
+ "passport_number": "X4R7T2K9P",
128
+ "surname": "MORGAN",
129
+ "given_names": "OLIVIA ROSE",
130
+ "sex": "F",
131
+ "date_of_birth": "1990-03-14",
132
+ "place_of_birth": "ZENITH CITY",
133
+ "date_of_issue": "2024-07-16",
134
+ "date_of_expiry": "2034-07-15",
135
+ "place_of_issue": null
136
+ }
137
+ }
138
+ ```
139
+
140
+ PDF paths work the same way:
141
+
142
+ ```python
143
+ result = client.scan_invoice("./invoice.pdf")
144
+ ```
145
+
146
+ FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
147
+
148
+ ```python
149
+ content = await upload.read()
150
+ result = client.scan_passport(content)
151
+ ```
152
+
153
+ ## Methods
154
+
155
+ ```text
156
+ scan_passport(file)
157
+ scan_national_id(file)
158
+ scan_driver_license(file)
159
+ scan_driver_license_pdf417(file)
160
+ scan_health_card(file)
161
+ scan_proof_of_address(file)
162
+ scan_visa(file)
163
+ scan_vin(file)
164
+ scan_vin_pro(file)
165
+ scan_license_plate(file)
166
+ scan_vehicle_registration(file)
167
+ scan_auto_insurance(file)
168
+ scan_invoice(file)
169
+ scan_receipt(file)
170
+ scan_container(file)
171
+ scan_bill_of_lading(file)
172
+ scan_weighbridge_ticket(file)
173
+ scan_atm_cassette(file)
174
+ scan_hin(file)
175
+ get_account_balance()
176
+ ```
177
+
178
+ All document methods accept a local path or bytes, up to 4.5MB. Most methods support JPG, PNG, WebP, and PDF. `scan_driver_license_pdf417` accepts JPG, PNG, and WebP only.
179
+
180
+ The Receipt endpoint returns v2 by default. Enhanced accuracy costs 2 credits instead of the standard 1 credit and is enabled with the `accuracy` parameter:
181
+
182
+ ```python
183
+ receipt = client.scan_receipt(
184
+ "./receipt.jpg",
185
+ accuracy="enhanced",
186
+ )
187
+ ```
188
+
189
+ `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
190
+
191
+ Proof of Address example:
192
+
193
+ ```python
194
+ poa = client.scan_proof_of_address("./utility-bill.pdf")
195
+ if poa.get("success"):
196
+ print(poa["data"]["address"], poa["data"]["validation"]["is_within_90_days"])
197
+ ```
198
+
199
+ Travel Visa example:
200
+
201
+ ```python
202
+ visa = client.scan_visa("./visa-sticker.jpg")
203
+ if visa.get("success"):
204
+ print(visa["data"]["visa_number"], visa["data"]["validation"]["mrz_checksum_valid"])
205
+ ```
206
+
207
+ Bill of Lading & freight example:
208
+
209
+ ```python
210
+ bol = client.scan_bill_of_lading("./bill-of-lading.pdf")
211
+ if bol.get("success"):
212
+ print(bol["data"]["document_type"], bol["data"]["containers"], bol["data"]["validation"])
213
+ ```
214
+
215
+ US driver license PDF417 example:
216
+
217
+ ```python
218
+ result = client.scan_driver_license_pdf417("./license-back.jpg")
219
+ if result.get("success"):
220
+ print(result["data"]["document_number"])
221
+ ```
222
+
223
+ Weighbridge ticket example:
224
+
225
+ ```python
226
+ result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
227
+ if result.get("success"):
228
+ print(result["data"]["weights"])
229
+ print(result["data"]["validation"])
230
+ ```
231
+
232
+ ## Configuration
233
+
234
+ ```python
235
+ client = StructOCR(
236
+ api_key="YOUR_API_KEY",
237
+ base_url="https://api.structocr.com/v1",
238
+ timeout=60,
239
+ )
240
+ ```
241
+
242
+ See the [API documentation](https://structocr.com/developers?utm_source=pypi&utm_medium=readme&utm_campaign=sdk) for endpoint-specific response schemas and error codes.
243
+
244
+ ## Errors
245
+
246
+ API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
247
+
248
+ ```python
249
+ from structocr import StructOCRError
250
+
251
+ try:
252
+ client.scan_passport("./passport.jpg")
253
+ except StructOCRError as error:
254
+ print(error.status_code, error.code, error.retryable)
255
+ ```
256
+
257
+ `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
258
+
259
+ ## License
260
+
261
+ MIT
@@ -0,0 +1,225 @@
1
+ # StructOCR Python SDK
2
+
3
+ Official Python client for the [StructOCR API](https://structocr.com/developers?utm_source=pypi&utm_medium=readme&utm_campaign=sdk).
4
+
5
+ Extract validated, structured JSON from 19 document types — spanning identity & KYC (passports, travel visas, proof of address, national IDs, driver licenses, PDF417 barcodes, health insurance cards), vehicles & insurance (VIN, VIN Pro vehicle decode, license plates, registrations, auto insurance cards), finance (invoices, receipts), and logistics (bills of lading, shipping containers, weighbridge tickets, ATM cassettes, boat HINs). One method call per document, zero template training.
6
+
7
+ The SDK accepts a local JPG, PNG, WebP, or PDF path, plus in-memory `bytes`. It validates the decoded file locally, converts it to Base64, and sends JSON as `{"img": "..."}`. The REST API also supports multipart uploads; this SDK release keeps Base64 JSON as its default transport for backward compatibility.
8
+
9
+ ## Get a free API key
10
+
11
+ 1. [Create an account](https://structocr.com/register?utm_source=pypi&utm_medium=readme&utm_campaign=sdk). New accounts get **200 free credits**, enough for 100 two-credit document scans, and no credit card is needed.
12
+ 2. Copy your key from **API Keys** in the dashboard.
13
+ 3. Optionally test any of the 19 endpoints on a sample image in the [Playground](https://structocr.com/dashboard/playground?utm_source=pypi&utm_medium=readme&utm_campaign=sdk) before you write code.
14
+
15
+ Not ready to sign up? Try documents directly in your browser on a sample image or your own file, no account needed: use the **Try it** links in the table below.
16
+
17
+ After the free credits, packs start at $5 for 500 credits. There is no subscription and credits do not expire. See [pricing](https://structocr.com/pricing?utm_source=pypi&utm_medium=readme&utm_campaign=sdk).
18
+
19
+ ## Supported documents
20
+
21
+ | Document | Method | Credits per scan | Try it |
22
+ | --- | --- | --- | --- |
23
+ | Passport | `scan_passport` | 2 | [Try it](https://structocr.com/products/passport-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
24
+ | Driver license (front) | `scan_driver_license` | 2 | [Try it](https://structocr.com/products/driver-license-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
25
+ | US/Canada driver license PDF417 barcode | `scan_driver_license_pdf417` | 2 | [Try it](https://structocr.com/tools/driver-license-pdf417-scanner?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try) |
26
+ | National ID card | `scan_national_id` | 2 | [Try it](https://structocr.com/products/national-id-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
27
+ | Health insurance card *(New)* | `scan_health_card` | 2 | [Try it](https://structocr.com/products/health-card-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
28
+ | Proof of Address *(New)* | `scan_proof_of_address` | 2 | [Try it](https://structocr.com/products/proof-of-address-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
29
+ | Travel visa (MRV-A/B & eVisa) *(New)* | `scan_visa` | 2 | [Try it](https://structocr.com/products/visa-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
30
+ | VIN | `scan_vin` | 1 | [Try it](https://structocr.com/products/vin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
31
+ | VIN Pro (VIN + vehicle details) *(New)* | `scan_vin_pro` | 2 | |
32
+ | License plate | `scan_license_plate` | 1 | [Try it](https://structocr.com/products/license-plate-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
33
+ | Vehicle registration | `scan_vehicle_registration` | 2 | [Try it](https://structocr.com/products/vehicle-registration-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
34
+ | Auto insurance card *(New)* | `scan_auto_insurance` | 2 | [Try it](https://structocr.com/products/auto-insurance-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
35
+ | Invoice | `scan_invoice` | 3 | [Try it](https://structocr.com/products/invoice-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
36
+ | Receipt | `scan_receipt` | 1 | [Try it](https://structocr.com/products/receipt-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
37
+ | Shipping container (ISO 6346) | `scan_container` | 1 | [Try it](https://structocr.com/products/container-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
38
+ | Bill of Lading & freight *(New)* | `scan_bill_of_lading` | 3 | [Try it](https://structocr.com/products/bill-of-lading-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
39
+ | Weighbridge ticket | `scan_weighbridge_ticket` | 2 | [Try it](https://structocr.com/products/weighbridge-ticket-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
40
+ | ATM cassette | `scan_atm_cassette` | 1 | |
41
+ | HIN (boat hull number) | `scan_hin` | 1 | [Try it](https://structocr.com/products/hin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
42
+
43
+ The receipt endpoint's optional enhanced mode costs 2 credits. Only successful requests are charged.
44
+
45
+ ## What's new in v1.8.0
46
+
47
+ Added native SDK methods for all six newly launched StructOCR endpoints:
48
+
49
+ - **`scan_proof_of_address(file)`** (`POST /v1/proof-of-address`, 2 credits) — Utility bills, bank statements, tax notices, and leases with 90/180-day freshness and PO Box checks.
50
+ - **`scan_visa(file)`** (`POST /v1/visa`, 2 credits) — Passport visa stickers (ICAO 9303 MRV-A 2×44 & MRV-B 2×36 check-digit verification) and global eVisa PDFs.
51
+ - **`scan_bill_of_lading(file)`** (`POST /v1/bill-of-lading`, 3 credits) — Ocean/road Bills of Lading, Packing Lists, Air Waybills (IATA Mod-7 validation), Commercial Invoices, and signed PODs with ISO 6346 container checks and cargo weight reconciliation.
52
+ - **`scan_health_card(file)`** (`POST /v1/health-card`, 2 credits) — US health insurance cards (Member ID, Group, RxBIN/RxPCN/RxGRP, copays), GCC/Canada/India/Brazil medical cards, and EU Tessera Sanitaria/EHIC, including 2-page front+back PDFs.
53
+ - **`scan_auto_insurance(file)`** (`POST /v1/auto-insurance`, 2 credits) — US ACORD 50 / state proof of insurance and Canadian Pink Cards with NAIC, policy date, and VIN check-digit validation.
54
+ - **`scan_vin_pro(file)`** (`POST /v1/vin-pro`, 2 credits) — VIN OCR with ISO 3779 check-digit validation plus decoded vehicle year, make, model, trim, engine, and body class.
55
+
56
+ ## Install
57
+
58
+ ```bash
59
+ pip install --upgrade structocr
60
+ ```
61
+
62
+ Python 3.7+ is required.
63
+
64
+ ## Quick start
65
+
66
+ ```bash
67
+ export STRUCTOCR_API_KEY="YOUR_API_KEY"
68
+ ```
69
+
70
+ ```python
71
+ from structocr import StructOCR
72
+
73
+ client = StructOCR()
74
+ result = client.scan_passport("./passport.jpg")
75
+
76
+ if result.get("success"):
77
+ data = result["data"]
78
+ print(data.get("passport_number"))
79
+ print(data.get("given_names"), data.get("surname"))
80
+ ```
81
+
82
+ A passport scan returns JSON like this (fictional sample document):
83
+
84
+ ```json
85
+ {
86
+ "success": true,
87
+ "data": {
88
+ "type": "passport",
89
+ "country_code": "UTO",
90
+ "nationality": "UTOPIAN",
91
+ "passport_number": "X4R7T2K9P",
92
+ "surname": "MORGAN",
93
+ "given_names": "OLIVIA ROSE",
94
+ "sex": "F",
95
+ "date_of_birth": "1990-03-14",
96
+ "place_of_birth": "ZENITH CITY",
97
+ "date_of_issue": "2024-07-16",
98
+ "date_of_expiry": "2034-07-15",
99
+ "place_of_issue": null
100
+ }
101
+ }
102
+ ```
103
+
104
+ PDF paths work the same way:
105
+
106
+ ```python
107
+ result = client.scan_invoice("./invoice.pdf")
108
+ ```
109
+
110
+ FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
111
+
112
+ ```python
113
+ content = await upload.read()
114
+ result = client.scan_passport(content)
115
+ ```
116
+
117
+ ## Methods
118
+
119
+ ```text
120
+ scan_passport(file)
121
+ scan_national_id(file)
122
+ scan_driver_license(file)
123
+ scan_driver_license_pdf417(file)
124
+ scan_health_card(file)
125
+ scan_proof_of_address(file)
126
+ scan_visa(file)
127
+ scan_vin(file)
128
+ scan_vin_pro(file)
129
+ scan_license_plate(file)
130
+ scan_vehicle_registration(file)
131
+ scan_auto_insurance(file)
132
+ scan_invoice(file)
133
+ scan_receipt(file)
134
+ scan_container(file)
135
+ scan_bill_of_lading(file)
136
+ scan_weighbridge_ticket(file)
137
+ scan_atm_cassette(file)
138
+ scan_hin(file)
139
+ get_account_balance()
140
+ ```
141
+
142
+ All document methods accept a local path or bytes, up to 4.5MB. Most methods support JPG, PNG, WebP, and PDF. `scan_driver_license_pdf417` accepts JPG, PNG, and WebP only.
143
+
144
+ The Receipt endpoint returns v2 by default. Enhanced accuracy costs 2 credits instead of the standard 1 credit and is enabled with the `accuracy` parameter:
145
+
146
+ ```python
147
+ receipt = client.scan_receipt(
148
+ "./receipt.jpg",
149
+ accuracy="enhanced",
150
+ )
151
+ ```
152
+
153
+ `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
154
+
155
+ Proof of Address example:
156
+
157
+ ```python
158
+ poa = client.scan_proof_of_address("./utility-bill.pdf")
159
+ if poa.get("success"):
160
+ print(poa["data"]["address"], poa["data"]["validation"]["is_within_90_days"])
161
+ ```
162
+
163
+ Travel Visa example:
164
+
165
+ ```python
166
+ visa = client.scan_visa("./visa-sticker.jpg")
167
+ if visa.get("success"):
168
+ print(visa["data"]["visa_number"], visa["data"]["validation"]["mrz_checksum_valid"])
169
+ ```
170
+
171
+ Bill of Lading & freight example:
172
+
173
+ ```python
174
+ bol = client.scan_bill_of_lading("./bill-of-lading.pdf")
175
+ if bol.get("success"):
176
+ print(bol["data"]["document_type"], bol["data"]["containers"], bol["data"]["validation"])
177
+ ```
178
+
179
+ US driver license PDF417 example:
180
+
181
+ ```python
182
+ result = client.scan_driver_license_pdf417("./license-back.jpg")
183
+ if result.get("success"):
184
+ print(result["data"]["document_number"])
185
+ ```
186
+
187
+ Weighbridge ticket example:
188
+
189
+ ```python
190
+ result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
191
+ if result.get("success"):
192
+ print(result["data"]["weights"])
193
+ print(result["data"]["validation"])
194
+ ```
195
+
196
+ ## Configuration
197
+
198
+ ```python
199
+ client = StructOCR(
200
+ api_key="YOUR_API_KEY",
201
+ base_url="https://api.structocr.com/v1",
202
+ timeout=60,
203
+ )
204
+ ```
205
+
206
+ See the [API documentation](https://structocr.com/developers?utm_source=pypi&utm_medium=readme&utm_campaign=sdk) for endpoint-specific response schemas and error codes.
207
+
208
+ ## Errors
209
+
210
+ API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
211
+
212
+ ```python
213
+ from structocr import StructOCRError
214
+
215
+ try:
216
+ client.scan_passport("./passport.jpg")
217
+ except StructOCRError as error:
218
+ print(error.status_code, error.code, error.retryable)
219
+ ```
220
+
221
+ `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
222
+
223
+ ## License
224
+
225
+ MIT
@@ -9,7 +9,8 @@ exec((ROOT / "structocr" / "version.py").read_text(encoding="utf-8"), VERSION)
9
9
  setup(
10
10
  name="structocr",
11
11
  version=VERSION["__version__"],
12
- description="Official Python SDK for StructOCR Base64 document APIs, including images, PDFs, and account balance.",
12
+ description="Structured OCR API SDK for Python: passports, visas, proof of address, health cards, IDs, driver licenses, auto insurance, VIN Pro, invoices, receipts, and bills of lading.",
13
+ keywords=["ocr", "passport ocr", "mrz", "id card ocr", "driver license ocr", "pdf417", "health card ocr", "proof of address ocr", "visa ocr", "vin ocr", "vin pro ocr", "auto insurance ocr", "invoice ocr", "receipt ocr", "bill of lading ocr", "freight ocr", "kyc", "document ai", "structocr"],
13
14
  long_description=(ROOT / "README.md").read_text(encoding="utf-8"),
14
15
  long_description_content_type="text/markdown",
15
16
  license="MIT",
@@ -22,7 +23,8 @@ setup(
22
23
 
23
24
  project_urls={
24
25
  "Homepage": "https://structocr.com",
25
- "Documentation": "https://structocr.com/developers",
26
+ "Documentation": "https://structocr.com/developers",
27
+ "Get a free API key": "https://structocr.com/register?utm_source=pypi&utm_medium=project_urls&utm_campaign=sdk",
26
28
  "Source": "https://github.com/dracula911/structocr-python",
27
29
  "Tracker": "https://github.com/dracula911/structocr-python/issues",
28
30
  },
@@ -191,15 +191,30 @@ class StructOCR:
191
191
  def scan_driver_license_pdf417(self, file: FileInput) -> Dict[str, Any]:
192
192
  return self._post_image("driver-license-pdf417", file, allow_pdf=False)
193
193
 
194
+ def scan_health_card(self, file: FileInput) -> Dict[str, Any]:
195
+ return self._post_image("health-card", file)
196
+
197
+ def scan_proof_of_address(self, file: FileInput) -> Dict[str, Any]:
198
+ return self._post_image("proof-of-address", file)
199
+
200
+ def scan_visa(self, file: FileInput) -> Dict[str, Any]:
201
+ return self._post_image("visa", file)
202
+
194
203
  def scan_invoice(self, file: FileInput) -> Dict[str, Any]:
195
204
  return self._post_image("invoice", file)
196
205
 
197
206
  def scan_vin(self, file: FileInput) -> Dict[str, Any]:
198
207
  return self._post_image("vin", file)
199
208
 
209
+ def scan_vin_pro(self, file: FileInput) -> Dict[str, Any]:
210
+ return self._post_image("vin-pro", file)
211
+
200
212
  def scan_container(self, file: FileInput) -> Dict[str, Any]:
201
213
  return self._post_image("container", file)
202
214
 
215
+ def scan_bill_of_lading(self, file: FileInput) -> Dict[str, Any]:
216
+ return self._post_image("bill-of-lading", file)
217
+
203
218
  def scan_hin(self, file: FileInput) -> Dict[str, Any]:
204
219
  return self._post_image("hin", file)
205
220
 
@@ -238,6 +253,9 @@ class StructOCR:
238
253
  def scan_vehicle_registration(self, file: FileInput) -> Dict[str, Any]:
239
254
  return self._post_image("vehicle-registration", file)
240
255
 
256
+ def scan_auto_insurance(self, file: FileInput) -> Dict[str, Any]:
257
+ return self._post_image("auto-insurance", file)
258
+
241
259
  def scan_atm_cassette(self, file: FileInput) -> Dict[str, Any]:
242
260
  return self._post_image("atm-cassette", file)
243
261
 
@@ -0,0 +1 @@
1
+ __version__ = "1.8.0"
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.4
2
+ Name: structocr
3
+ Version: 1.8.0
4
+ Summary: Structured OCR API SDK for Python: passports, visas, proof of address, health cards, IDs, driver licenses, auto insurance, VIN Pro, invoices, receipts, and bills of lading.
5
+ Home-page: https://structocr.com
6
+ Author: StructOCR Team
7
+ Author-email: support@structocr.com
8
+ License: MIT
9
+ Project-URL: Homepage, https://structocr.com
10
+ Project-URL: Documentation, https://structocr.com/developers
11
+ Project-URL: Get a free API key, https://structocr.com/register?utm_source=pypi&utm_medium=project_urls&utm_campaign=sdk
12
+ Project-URL: Source, https://github.com/dracula911/structocr-python
13
+ Project-URL: Tracker, https://github.com/dracula911/structocr-python/issues
14
+ Keywords: ocr,passport ocr,mrz,id card ocr,driver license ocr,pdf417,health card ocr,proof of address ocr,visa ocr,vin ocr,vin pro ocr,auto insurance ocr,invoice ocr,receipt ocr,bill of lading ocr,freight ocr,kyc,document ai,structocr
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
19
+ Requires-Python: >=3.7
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests>=2.25.0
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: keywords
30
+ Dynamic: license
31
+ Dynamic: license-file
32
+ Dynamic: project-url
33
+ Dynamic: requires-dist
34
+ Dynamic: requires-python
35
+ Dynamic: summary
36
+
37
+ # StructOCR Python SDK
38
+
39
+ Official Python client for the [StructOCR API](https://structocr.com/developers?utm_source=pypi&utm_medium=readme&utm_campaign=sdk).
40
+
41
+ Extract validated, structured JSON from 19 document types — spanning identity & KYC (passports, travel visas, proof of address, national IDs, driver licenses, PDF417 barcodes, health insurance cards), vehicles & insurance (VIN, VIN Pro vehicle decode, license plates, registrations, auto insurance cards), finance (invoices, receipts), and logistics (bills of lading, shipping containers, weighbridge tickets, ATM cassettes, boat HINs). One method call per document, zero template training.
42
+
43
+ The SDK accepts a local JPG, PNG, WebP, or PDF path, plus in-memory `bytes`. It validates the decoded file locally, converts it to Base64, and sends JSON as `{"img": "..."}`. The REST API also supports multipart uploads; this SDK release keeps Base64 JSON as its default transport for backward compatibility.
44
+
45
+ ## Get a free API key
46
+
47
+ 1. [Create an account](https://structocr.com/register?utm_source=pypi&utm_medium=readme&utm_campaign=sdk). New accounts get **200 free credits**, enough for 100 two-credit document scans, and no credit card is needed.
48
+ 2. Copy your key from **API Keys** in the dashboard.
49
+ 3. Optionally test any of the 19 endpoints on a sample image in the [Playground](https://structocr.com/dashboard/playground?utm_source=pypi&utm_medium=readme&utm_campaign=sdk) before you write code.
50
+
51
+ Not ready to sign up? Try documents directly in your browser on a sample image or your own file, no account needed: use the **Try it** links in the table below.
52
+
53
+ After the free credits, packs start at $5 for 500 credits. There is no subscription and credits do not expire. See [pricing](https://structocr.com/pricing?utm_source=pypi&utm_medium=readme&utm_campaign=sdk).
54
+
55
+ ## Supported documents
56
+
57
+ | Document | Method | Credits per scan | Try it |
58
+ | --- | --- | --- | --- |
59
+ | Passport | `scan_passport` | 2 | [Try it](https://structocr.com/products/passport-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
60
+ | Driver license (front) | `scan_driver_license` | 2 | [Try it](https://structocr.com/products/driver-license-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
61
+ | US/Canada driver license PDF417 barcode | `scan_driver_license_pdf417` | 2 | [Try it](https://structocr.com/tools/driver-license-pdf417-scanner?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try) |
62
+ | National ID card | `scan_national_id` | 2 | [Try it](https://structocr.com/products/national-id-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
63
+ | Health insurance card *(New)* | `scan_health_card` | 2 | [Try it](https://structocr.com/products/health-card-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
64
+ | Proof of Address *(New)* | `scan_proof_of_address` | 2 | [Try it](https://structocr.com/products/proof-of-address-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
65
+ | Travel visa (MRV-A/B & eVisa) *(New)* | `scan_visa` | 2 | [Try it](https://structocr.com/products/visa-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
66
+ | VIN | `scan_vin` | 1 | [Try it](https://structocr.com/products/vin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
67
+ | VIN Pro (VIN + vehicle details) *(New)* | `scan_vin_pro` | 2 | |
68
+ | License plate | `scan_license_plate` | 1 | [Try it](https://structocr.com/products/license-plate-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
69
+ | Vehicle registration | `scan_vehicle_registration` | 2 | [Try it](https://structocr.com/products/vehicle-registration-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
70
+ | Auto insurance card *(New)* | `scan_auto_insurance` | 2 | [Try it](https://structocr.com/products/auto-insurance-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
71
+ | Invoice | `scan_invoice` | 3 | [Try it](https://structocr.com/products/invoice-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
72
+ | Receipt | `scan_receipt` | 1 | [Try it](https://structocr.com/products/receipt-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
73
+ | Shipping container (ISO 6346) | `scan_container` | 1 | [Try it](https://structocr.com/products/container-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
74
+ | Bill of Lading & freight *(New)* | `scan_bill_of_lading` | 3 | [Try it](https://structocr.com/products/bill-of-lading-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
75
+ | Weighbridge ticket | `scan_weighbridge_ticket` | 2 | [Try it](https://structocr.com/products/weighbridge-ticket-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
76
+ | ATM cassette | `scan_atm_cassette` | 1 | |
77
+ | HIN (boat hull number) | `scan_hin` | 1 | [Try it](https://structocr.com/products/hin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
78
+
79
+ The receipt endpoint's optional enhanced mode costs 2 credits. Only successful requests are charged.
80
+
81
+ ## What's new in v1.8.0
82
+
83
+ Added native SDK methods for all six newly launched StructOCR endpoints:
84
+
85
+ - **`scan_proof_of_address(file)`** (`POST /v1/proof-of-address`, 2 credits) — Utility bills, bank statements, tax notices, and leases with 90/180-day freshness and PO Box checks.
86
+ - **`scan_visa(file)`** (`POST /v1/visa`, 2 credits) — Passport visa stickers (ICAO 9303 MRV-A 2×44 & MRV-B 2×36 check-digit verification) and global eVisa PDFs.
87
+ - **`scan_bill_of_lading(file)`** (`POST /v1/bill-of-lading`, 3 credits) — Ocean/road Bills of Lading, Packing Lists, Air Waybills (IATA Mod-7 validation), Commercial Invoices, and signed PODs with ISO 6346 container checks and cargo weight reconciliation.
88
+ - **`scan_health_card(file)`** (`POST /v1/health-card`, 2 credits) — US health insurance cards (Member ID, Group, RxBIN/RxPCN/RxGRP, copays), GCC/Canada/India/Brazil medical cards, and EU Tessera Sanitaria/EHIC, including 2-page front+back PDFs.
89
+ - **`scan_auto_insurance(file)`** (`POST /v1/auto-insurance`, 2 credits) — US ACORD 50 / state proof of insurance and Canadian Pink Cards with NAIC, policy date, and VIN check-digit validation.
90
+ - **`scan_vin_pro(file)`** (`POST /v1/vin-pro`, 2 credits) — VIN OCR with ISO 3779 check-digit validation plus decoded vehicle year, make, model, trim, engine, and body class.
91
+
92
+ ## Install
93
+
94
+ ```bash
95
+ pip install --upgrade structocr
96
+ ```
97
+
98
+ Python 3.7+ is required.
99
+
100
+ ## Quick start
101
+
102
+ ```bash
103
+ export STRUCTOCR_API_KEY="YOUR_API_KEY"
104
+ ```
105
+
106
+ ```python
107
+ from structocr import StructOCR
108
+
109
+ client = StructOCR()
110
+ result = client.scan_passport("./passport.jpg")
111
+
112
+ if result.get("success"):
113
+ data = result["data"]
114
+ print(data.get("passport_number"))
115
+ print(data.get("given_names"), data.get("surname"))
116
+ ```
117
+
118
+ A passport scan returns JSON like this (fictional sample document):
119
+
120
+ ```json
121
+ {
122
+ "success": true,
123
+ "data": {
124
+ "type": "passport",
125
+ "country_code": "UTO",
126
+ "nationality": "UTOPIAN",
127
+ "passport_number": "X4R7T2K9P",
128
+ "surname": "MORGAN",
129
+ "given_names": "OLIVIA ROSE",
130
+ "sex": "F",
131
+ "date_of_birth": "1990-03-14",
132
+ "place_of_birth": "ZENITH CITY",
133
+ "date_of_issue": "2024-07-16",
134
+ "date_of_expiry": "2034-07-15",
135
+ "place_of_issue": null
136
+ }
137
+ }
138
+ ```
139
+
140
+ PDF paths work the same way:
141
+
142
+ ```python
143
+ result = client.scan_invoice("./invoice.pdf")
144
+ ```
145
+
146
+ FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
147
+
148
+ ```python
149
+ content = await upload.read()
150
+ result = client.scan_passport(content)
151
+ ```
152
+
153
+ ## Methods
154
+
155
+ ```text
156
+ scan_passport(file)
157
+ scan_national_id(file)
158
+ scan_driver_license(file)
159
+ scan_driver_license_pdf417(file)
160
+ scan_health_card(file)
161
+ scan_proof_of_address(file)
162
+ scan_visa(file)
163
+ scan_vin(file)
164
+ scan_vin_pro(file)
165
+ scan_license_plate(file)
166
+ scan_vehicle_registration(file)
167
+ scan_auto_insurance(file)
168
+ scan_invoice(file)
169
+ scan_receipt(file)
170
+ scan_container(file)
171
+ scan_bill_of_lading(file)
172
+ scan_weighbridge_ticket(file)
173
+ scan_atm_cassette(file)
174
+ scan_hin(file)
175
+ get_account_balance()
176
+ ```
177
+
178
+ All document methods accept a local path or bytes, up to 4.5MB. Most methods support JPG, PNG, WebP, and PDF. `scan_driver_license_pdf417` accepts JPG, PNG, and WebP only.
179
+
180
+ The Receipt endpoint returns v2 by default. Enhanced accuracy costs 2 credits instead of the standard 1 credit and is enabled with the `accuracy` parameter:
181
+
182
+ ```python
183
+ receipt = client.scan_receipt(
184
+ "./receipt.jpg",
185
+ accuracy="enhanced",
186
+ )
187
+ ```
188
+
189
+ `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
190
+
191
+ Proof of Address example:
192
+
193
+ ```python
194
+ poa = client.scan_proof_of_address("./utility-bill.pdf")
195
+ if poa.get("success"):
196
+ print(poa["data"]["address"], poa["data"]["validation"]["is_within_90_days"])
197
+ ```
198
+
199
+ Travel Visa example:
200
+
201
+ ```python
202
+ visa = client.scan_visa("./visa-sticker.jpg")
203
+ if visa.get("success"):
204
+ print(visa["data"]["visa_number"], visa["data"]["validation"]["mrz_checksum_valid"])
205
+ ```
206
+
207
+ Bill of Lading & freight example:
208
+
209
+ ```python
210
+ bol = client.scan_bill_of_lading("./bill-of-lading.pdf")
211
+ if bol.get("success"):
212
+ print(bol["data"]["document_type"], bol["data"]["containers"], bol["data"]["validation"])
213
+ ```
214
+
215
+ US driver license PDF417 example:
216
+
217
+ ```python
218
+ result = client.scan_driver_license_pdf417("./license-back.jpg")
219
+ if result.get("success"):
220
+ print(result["data"]["document_number"])
221
+ ```
222
+
223
+ Weighbridge ticket example:
224
+
225
+ ```python
226
+ result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
227
+ if result.get("success"):
228
+ print(result["data"]["weights"])
229
+ print(result["data"]["validation"])
230
+ ```
231
+
232
+ ## Configuration
233
+
234
+ ```python
235
+ client = StructOCR(
236
+ api_key="YOUR_API_KEY",
237
+ base_url="https://api.structocr.com/v1",
238
+ timeout=60,
239
+ )
240
+ ```
241
+
242
+ See the [API documentation](https://structocr.com/developers?utm_source=pypi&utm_medium=readme&utm_campaign=sdk) for endpoint-specific response schemas and error codes.
243
+
244
+ ## Errors
245
+
246
+ API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
247
+
248
+ ```python
249
+ from structocr import StructOCRError
250
+
251
+ try:
252
+ client.scan_passport("./passport.jpg")
253
+ except StructOCRError as error:
254
+ print(error.status_code, error.code, error.retryable)
255
+ ```
256
+
257
+ `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
258
+
259
+ ## License
260
+
261
+ MIT
structocr-1.7.0/PKG-INFO DELETED
@@ -1,157 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: structocr
3
- Version: 1.7.0
4
- Summary: Official Python SDK for StructOCR Base64 document APIs, including images, PDFs, and account balance.
5
- Home-page: https://structocr.com
6
- Author: StructOCR Team
7
- Author-email: support@structocr.com
8
- License: MIT
9
- Project-URL: Homepage, https://structocr.com
10
- Project-URL: Documentation, https://structocr.com/developers
11
- Project-URL: Source, https://github.com/dracula911/structocr-python
12
- Project-URL: Tracker, https://github.com/dracula911/structocr-python/issues
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Operating System :: OS Independent
16
- Classifier: Topic :: Scientific/Engineering :: Image Recognition
17
- Requires-Python: >=3.7
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: requests>=2.25.0
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: classifier
24
- Dynamic: description
25
- Dynamic: description-content-type
26
- Dynamic: home-page
27
- Dynamic: license
28
- Dynamic: license-file
29
- Dynamic: project-url
30
- Dynamic: requires-dist
31
- Dynamic: requires-python
32
- Dynamic: summary
33
-
34
- # StructOCR Python SDK
35
-
36
- Official Python client for the [StructOCR API](https://structocr.com/developers).
37
-
38
- The SDK accepts a local JPG, PNG, WebP, or PDF path, plus in-memory `bytes`. It validates the decoded file locally, converts it to Base64, and sends JSON as `{"img": "..."}`. The REST API also supports multipart uploads; this SDK release keeps Base64 JSON as its default transport for backward compatibility.
39
-
40
- ## Install
41
-
42
- ```bash
43
- pip install --upgrade structocr
44
- ```
45
-
46
- Python 3.7+ is required.
47
-
48
- ## Quick start
49
-
50
- ```bash
51
- export STRUCTOCR_API_KEY="YOUR_API_KEY"
52
- ```
53
-
54
- ```python
55
- from structocr import StructOCR
56
-
57
- client = StructOCR()
58
- result = client.scan_passport("./passport.jpg")
59
-
60
- if result.get("success"):
61
- data = result["data"]
62
- print(data.get("passport_number"))
63
- print(data.get("given_names"), data.get("surname"))
64
- ```
65
-
66
- PDF paths work the same way:
67
-
68
- ```python
69
- result = client.scan_invoice("./invoice.pdf")
70
- ```
71
-
72
- FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
73
-
74
- ```python
75
- content = await upload.read()
76
- result = client.scan_passport(content)
77
- ```
78
-
79
- ## Methods
80
-
81
- ```text
82
- scan_passport(file)
83
- scan_national_id(file)
84
- scan_driver_license(file)
85
- scan_driver_license_pdf417(file)
86
- scan_invoice(file)
87
- scan_receipt(file)
88
- scan_vin(file)
89
- scan_hin(file)
90
- scan_container(file)
91
- scan_license_plate(file)
92
- scan_vehicle_registration(file)
93
- scan_atm_cassette(file)
94
- scan_weighbridge_ticket(file)
95
- get_account_balance()
96
- ```
97
-
98
- All document methods accept a local path or bytes, up to 4.5MB. Most methods support JPG, PNG, WebP, and PDF. `scan_driver_license_pdf417` accepts JPG, PNG, and WebP only.
99
-
100
- The Receipt endpoint returns v2 by default. Enhanced accuracy costs 2 credits instead of the standard 1 credit and is enabled with the `accuracy` parameter:
101
-
102
- ```python
103
- receipt = client.scan_receipt(
104
- "./receipt.jpg",
105
- accuracy="enhanced",
106
- )
107
- ```
108
-
109
- `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
110
-
111
- US driver license PDF417 example:
112
-
113
- ```python
114
- result = client.scan_driver_license_pdf417("./license-back.jpg")
115
- if result.get("success"):
116
- print(result["data"]["document_number"])
117
- ```
118
-
119
- Weighbridge ticket example:
120
-
121
- ```python
122
- result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
123
- if result.get("success"):
124
- print(result["data"]["weights"])
125
- print(result["data"]["validation"])
126
- ```
127
-
128
- ## Configuration
129
-
130
- ```python
131
- client = StructOCR(
132
- api_key="YOUR_API_KEY",
133
- base_url="https://api.structocr.com/v1",
134
- timeout=60,
135
- )
136
- ```
137
-
138
- See the [API documentation](https://structocr.com/developers) for endpoint-specific response schemas and error codes.
139
-
140
- ## Errors
141
-
142
- API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
143
-
144
- ```python
145
- from structocr import StructOCRError
146
-
147
- try:
148
- client.scan_passport("./passport.jpg")
149
- except StructOCRError as error:
150
- print(error.status_code, error.code, error.retryable)
151
- ```
152
-
153
- `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
154
-
155
- ## License
156
-
157
- MIT
structocr-1.7.0/README.md DELETED
@@ -1,124 +0,0 @@
1
- # StructOCR Python SDK
2
-
3
- Official Python client for the [StructOCR API](https://structocr.com/developers).
4
-
5
- The SDK accepts a local JPG, PNG, WebP, or PDF path, plus in-memory `bytes`. It validates the decoded file locally, converts it to Base64, and sends JSON as `{"img": "..."}`. The REST API also supports multipart uploads; this SDK release keeps Base64 JSON as its default transport for backward compatibility.
6
-
7
- ## Install
8
-
9
- ```bash
10
- pip install --upgrade structocr
11
- ```
12
-
13
- Python 3.7+ is required.
14
-
15
- ## Quick start
16
-
17
- ```bash
18
- export STRUCTOCR_API_KEY="YOUR_API_KEY"
19
- ```
20
-
21
- ```python
22
- from structocr import StructOCR
23
-
24
- client = StructOCR()
25
- result = client.scan_passport("./passport.jpg")
26
-
27
- if result.get("success"):
28
- data = result["data"]
29
- print(data.get("passport_number"))
30
- print(data.get("given_names"), data.get("surname"))
31
- ```
32
-
33
- PDF paths work the same way:
34
-
35
- ```python
36
- result = client.scan_invoice("./invoice.pdf")
37
- ```
38
-
39
- FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
40
-
41
- ```python
42
- content = await upload.read()
43
- result = client.scan_passport(content)
44
- ```
45
-
46
- ## Methods
47
-
48
- ```text
49
- scan_passport(file)
50
- scan_national_id(file)
51
- scan_driver_license(file)
52
- scan_driver_license_pdf417(file)
53
- scan_invoice(file)
54
- scan_receipt(file)
55
- scan_vin(file)
56
- scan_hin(file)
57
- scan_container(file)
58
- scan_license_plate(file)
59
- scan_vehicle_registration(file)
60
- scan_atm_cassette(file)
61
- scan_weighbridge_ticket(file)
62
- get_account_balance()
63
- ```
64
-
65
- All document methods accept a local path or bytes, up to 4.5MB. Most methods support JPG, PNG, WebP, and PDF. `scan_driver_license_pdf417` accepts JPG, PNG, and WebP only.
66
-
67
- The Receipt endpoint returns v2 by default. Enhanced accuracy costs 2 credits instead of the standard 1 credit and is enabled with the `accuracy` parameter:
68
-
69
- ```python
70
- receipt = client.scan_receipt(
71
- "./receipt.jpg",
72
- accuracy="enhanced",
73
- )
74
- ```
75
-
76
- `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
77
-
78
- US driver license PDF417 example:
79
-
80
- ```python
81
- result = client.scan_driver_license_pdf417("./license-back.jpg")
82
- if result.get("success"):
83
- print(result["data"]["document_number"])
84
- ```
85
-
86
- Weighbridge ticket example:
87
-
88
- ```python
89
- result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
90
- if result.get("success"):
91
- print(result["data"]["weights"])
92
- print(result["data"]["validation"])
93
- ```
94
-
95
- ## Configuration
96
-
97
- ```python
98
- client = StructOCR(
99
- api_key="YOUR_API_KEY",
100
- base_url="https://api.structocr.com/v1",
101
- timeout=60,
102
- )
103
- ```
104
-
105
- See the [API documentation](https://structocr.com/developers) for endpoint-specific response schemas and error codes.
106
-
107
- ## Errors
108
-
109
- API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
110
-
111
- ```python
112
- from structocr import StructOCRError
113
-
114
- try:
115
- client.scan_passport("./passport.jpg")
116
- except StructOCRError as error:
117
- print(error.status_code, error.code, error.retryable)
118
- ```
119
-
120
- `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
121
-
122
- ## License
123
-
124
- MIT
@@ -1 +0,0 @@
1
- __version__ = "1.7.0"
@@ -1,157 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: structocr
3
- Version: 1.7.0
4
- Summary: Official Python SDK for StructOCR Base64 document APIs, including images, PDFs, and account balance.
5
- Home-page: https://structocr.com
6
- Author: StructOCR Team
7
- Author-email: support@structocr.com
8
- License: MIT
9
- Project-URL: Homepage, https://structocr.com
10
- Project-URL: Documentation, https://structocr.com/developers
11
- Project-URL: Source, https://github.com/dracula911/structocr-python
12
- Project-URL: Tracker, https://github.com/dracula911/structocr-python/issues
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Operating System :: OS Independent
16
- Classifier: Topic :: Scientific/Engineering :: Image Recognition
17
- Requires-Python: >=3.7
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: requests>=2.25.0
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: classifier
24
- Dynamic: description
25
- Dynamic: description-content-type
26
- Dynamic: home-page
27
- Dynamic: license
28
- Dynamic: license-file
29
- Dynamic: project-url
30
- Dynamic: requires-dist
31
- Dynamic: requires-python
32
- Dynamic: summary
33
-
34
- # StructOCR Python SDK
35
-
36
- Official Python client for the [StructOCR API](https://structocr.com/developers).
37
-
38
- The SDK accepts a local JPG, PNG, WebP, or PDF path, plus in-memory `bytes`. It validates the decoded file locally, converts it to Base64, and sends JSON as `{"img": "..."}`. The REST API also supports multipart uploads; this SDK release keeps Base64 JSON as its default transport for backward compatibility.
39
-
40
- ## Install
41
-
42
- ```bash
43
- pip install --upgrade structocr
44
- ```
45
-
46
- Python 3.7+ is required.
47
-
48
- ## Quick start
49
-
50
- ```bash
51
- export STRUCTOCR_API_KEY="YOUR_API_KEY"
52
- ```
53
-
54
- ```python
55
- from structocr import StructOCR
56
-
57
- client = StructOCR()
58
- result = client.scan_passport("./passport.jpg")
59
-
60
- if result.get("success"):
61
- data = result["data"]
62
- print(data.get("passport_number"))
63
- print(data.get("given_names"), data.get("surname"))
64
- ```
65
-
66
- PDF paths work the same way:
67
-
68
- ```python
69
- result = client.scan_invoice("./invoice.pdf")
70
- ```
71
-
72
- FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
73
-
74
- ```python
75
- content = await upload.read()
76
- result = client.scan_passport(content)
77
- ```
78
-
79
- ## Methods
80
-
81
- ```text
82
- scan_passport(file)
83
- scan_national_id(file)
84
- scan_driver_license(file)
85
- scan_driver_license_pdf417(file)
86
- scan_invoice(file)
87
- scan_receipt(file)
88
- scan_vin(file)
89
- scan_hin(file)
90
- scan_container(file)
91
- scan_license_plate(file)
92
- scan_vehicle_registration(file)
93
- scan_atm_cassette(file)
94
- scan_weighbridge_ticket(file)
95
- get_account_balance()
96
- ```
97
-
98
- All document methods accept a local path or bytes, up to 4.5MB. Most methods support JPG, PNG, WebP, and PDF. `scan_driver_license_pdf417` accepts JPG, PNG, and WebP only.
99
-
100
- The Receipt endpoint returns v2 by default. Enhanced accuracy costs 2 credits instead of the standard 1 credit and is enabled with the `accuracy` parameter:
101
-
102
- ```python
103
- receipt = client.scan_receipt(
104
- "./receipt.jpg",
105
- accuracy="enhanced",
106
- )
107
- ```
108
-
109
- `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
110
-
111
- US driver license PDF417 example:
112
-
113
- ```python
114
- result = client.scan_driver_license_pdf417("./license-back.jpg")
115
- if result.get("success"):
116
- print(result["data"]["document_number"])
117
- ```
118
-
119
- Weighbridge ticket example:
120
-
121
- ```python
122
- result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
123
- if result.get("success"):
124
- print(result["data"]["weights"])
125
- print(result["data"]["validation"])
126
- ```
127
-
128
- ## Configuration
129
-
130
- ```python
131
- client = StructOCR(
132
- api_key="YOUR_API_KEY",
133
- base_url="https://api.structocr.com/v1",
134
- timeout=60,
135
- )
136
- ```
137
-
138
- See the [API documentation](https://structocr.com/developers) for endpoint-specific response schemas and error codes.
139
-
140
- ## Errors
141
-
142
- API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
143
-
144
- ```python
145
- from structocr import StructOCRError
146
-
147
- try:
148
- client.scan_passport("./passport.jpg")
149
- except StructOCRError as error:
150
- print(error.status_code, error.code, error.retryable)
151
- ```
152
-
153
- `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
154
-
155
- ## License
156
-
157
- MIT
File without changes
File without changes
File without changes
File without changes