structocr 1.7.0__tar.gz → 1.7.1__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,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: structocr
3
+ Version: 1.7.1
4
+ Summary: Passport, ID card, driver license, VIN, invoice and receipt OCR: turn images and PDFs into structured JSON. Official StructOCR SDK for Python.
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,vin ocr,invoice ocr,receipt 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
+ Send a photo or PDF of a passport, ID card, driver license, VIN, invoice, receipt or shipping container and get structured JSON back: one method call per document, no templates to train.
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 passport or driver license scans, and no credit card is needed.
48
+ 2. Copy your key from **API Keys** in the dashboard.
49
+ 3. Optionally try any document type 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 any document 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
+ | 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) |
61
+ | 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) |
62
+ | 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) |
63
+ | 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) |
64
+ | VIN | `scan_vin` | 1 | [Try it](https://structocr.com/products/vin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
65
+ | 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) |
66
+ | Invoice | `scan_invoice` | 3 | [Try it](https://structocr.com/products/invoice-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
67
+ | Receipt | `scan_receipt` | 1 | [Try it](https://structocr.com/products/receipt-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
68
+ | 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) |
69
+ | 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) |
70
+ | ATM cassette | `scan_atm_cassette` | 1 | |
71
+ | 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) |
72
+
73
+ The receipt endpoint's optional enhanced mode costs 2 credits. Only successful requests are charged.
74
+
75
+ ## Install
76
+
77
+ ```bash
78
+ pip install --upgrade structocr
79
+ ```
80
+
81
+ Python 3.7+ is required.
82
+
83
+ ## Quick start
84
+
85
+ ```bash
86
+ export STRUCTOCR_API_KEY="YOUR_API_KEY"
87
+ ```
88
+
89
+ ```python
90
+ from structocr import StructOCR
91
+
92
+ client = StructOCR()
93
+ result = client.scan_passport("./passport.jpg")
94
+
95
+ if result.get("success"):
96
+ data = result["data"]
97
+ print(data.get("passport_number"))
98
+ print(data.get("given_names"), data.get("surname"))
99
+ ```
100
+
101
+ A passport scan returns JSON like this (fictional sample document):
102
+
103
+ ```json
104
+ {
105
+ "success": true,
106
+ "data": {
107
+ "type": "passport",
108
+ "country_code": "UTO",
109
+ "nationality": "UTOPIAN",
110
+ "passport_number": "X4R7T2K9P",
111
+ "surname": "MORGAN",
112
+ "given_names": "OLIVIA ROSE",
113
+ "sex": "F",
114
+ "date_of_birth": "1990-03-14",
115
+ "place_of_birth": "ZENITH CITY",
116
+ "date_of_issue": "2024-07-16",
117
+ "date_of_expiry": "2034-07-15",
118
+ "place_of_issue": null
119
+ }
120
+ }
121
+ ```
122
+
123
+ PDF paths work the same way:
124
+
125
+ ```python
126
+ result = client.scan_invoice("./invoice.pdf")
127
+ ```
128
+
129
+ FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
130
+
131
+ ```python
132
+ content = await upload.read()
133
+ result = client.scan_passport(content)
134
+ ```
135
+
136
+ ## Methods
137
+
138
+ ```text
139
+ scan_passport(file)
140
+ scan_national_id(file)
141
+ scan_driver_license(file)
142
+ scan_driver_license_pdf417(file)
143
+ scan_invoice(file)
144
+ scan_receipt(file)
145
+ scan_vin(file)
146
+ scan_hin(file)
147
+ scan_container(file)
148
+ scan_license_plate(file)
149
+ scan_vehicle_registration(file)
150
+ scan_atm_cassette(file)
151
+ scan_weighbridge_ticket(file)
152
+ get_account_balance()
153
+ ```
154
+
155
+ 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.
156
+
157
+ 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:
158
+
159
+ ```python
160
+ receipt = client.scan_receipt(
161
+ "./receipt.jpg",
162
+ accuracy="enhanced",
163
+ )
164
+ ```
165
+
166
+ `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
167
+
168
+ US driver license PDF417 example:
169
+
170
+ ```python
171
+ result = client.scan_driver_license_pdf417("./license-back.jpg")
172
+ if result.get("success"):
173
+ print(result["data"]["document_number"])
174
+ ```
175
+
176
+ Weighbridge ticket example:
177
+
178
+ ```python
179
+ result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
180
+ if result.get("success"):
181
+ print(result["data"]["weights"])
182
+ print(result["data"]["validation"])
183
+ ```
184
+
185
+ ## Configuration
186
+
187
+ ```python
188
+ client = StructOCR(
189
+ api_key="YOUR_API_KEY",
190
+ base_url="https://api.structocr.com/v1",
191
+ timeout=60,
192
+ )
193
+ ```
194
+
195
+ 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.
196
+
197
+ ## Errors
198
+
199
+ API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
200
+
201
+ ```python
202
+ from structocr import StructOCRError
203
+
204
+ try:
205
+ client.scan_passport("./passport.jpg")
206
+ except StructOCRError as error:
207
+ print(error.status_code, error.code, error.retryable)
208
+ ```
209
+
210
+ `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
211
+
212
+ ## License
213
+
214
+ MIT
@@ -0,0 +1,178 @@
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
+ Send a photo or PDF of a passport, ID card, driver license, VIN, invoice, receipt or shipping container and get structured JSON back: one method call per document, no templates to train.
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 passport or driver license scans, and no credit card is needed.
12
+ 2. Copy your key from **API Keys** in the dashboard.
13
+ 3. Optionally try any document type 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 any document 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
+ | 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) |
25
+ | 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) |
26
+ | 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) |
27
+ | 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) |
28
+ | VIN | `scan_vin` | 1 | [Try it](https://structocr.com/products/vin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
29
+ | 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) |
30
+ | Invoice | `scan_invoice` | 3 | [Try it](https://structocr.com/products/invoice-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
31
+ | Receipt | `scan_receipt` | 1 | [Try it](https://structocr.com/products/receipt-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
32
+ | 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) |
33
+ | 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) |
34
+ | ATM cassette | `scan_atm_cassette` | 1 | |
35
+ | 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) |
36
+
37
+ The receipt endpoint's optional enhanced mode costs 2 credits. Only successful requests are charged.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ pip install --upgrade structocr
43
+ ```
44
+
45
+ Python 3.7+ is required.
46
+
47
+ ## Quick start
48
+
49
+ ```bash
50
+ export STRUCTOCR_API_KEY="YOUR_API_KEY"
51
+ ```
52
+
53
+ ```python
54
+ from structocr import StructOCR
55
+
56
+ client = StructOCR()
57
+ result = client.scan_passport("./passport.jpg")
58
+
59
+ if result.get("success"):
60
+ data = result["data"]
61
+ print(data.get("passport_number"))
62
+ print(data.get("given_names"), data.get("surname"))
63
+ ```
64
+
65
+ A passport scan returns JSON like this (fictional sample document):
66
+
67
+ ```json
68
+ {
69
+ "success": true,
70
+ "data": {
71
+ "type": "passport",
72
+ "country_code": "UTO",
73
+ "nationality": "UTOPIAN",
74
+ "passport_number": "X4R7T2K9P",
75
+ "surname": "MORGAN",
76
+ "given_names": "OLIVIA ROSE",
77
+ "sex": "F",
78
+ "date_of_birth": "1990-03-14",
79
+ "place_of_birth": "ZENITH CITY",
80
+ "date_of_issue": "2024-07-16",
81
+ "date_of_expiry": "2034-07-15",
82
+ "place_of_issue": null
83
+ }
84
+ }
85
+ ```
86
+
87
+ PDF paths work the same way:
88
+
89
+ ```python
90
+ result = client.scan_invoice("./invoice.pdf")
91
+ ```
92
+
93
+ FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
94
+
95
+ ```python
96
+ content = await upload.read()
97
+ result = client.scan_passport(content)
98
+ ```
99
+
100
+ ## Methods
101
+
102
+ ```text
103
+ scan_passport(file)
104
+ scan_national_id(file)
105
+ scan_driver_license(file)
106
+ scan_driver_license_pdf417(file)
107
+ scan_invoice(file)
108
+ scan_receipt(file)
109
+ scan_vin(file)
110
+ scan_hin(file)
111
+ scan_container(file)
112
+ scan_license_plate(file)
113
+ scan_vehicle_registration(file)
114
+ scan_atm_cassette(file)
115
+ scan_weighbridge_ticket(file)
116
+ get_account_balance()
117
+ ```
118
+
119
+ 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.
120
+
121
+ 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:
122
+
123
+ ```python
124
+ receipt = client.scan_receipt(
125
+ "./receipt.jpg",
126
+ accuracy="enhanced",
127
+ )
128
+ ```
129
+
130
+ `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
131
+
132
+ US driver license PDF417 example:
133
+
134
+ ```python
135
+ result = client.scan_driver_license_pdf417("./license-back.jpg")
136
+ if result.get("success"):
137
+ print(result["data"]["document_number"])
138
+ ```
139
+
140
+ Weighbridge ticket example:
141
+
142
+ ```python
143
+ result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
144
+ if result.get("success"):
145
+ print(result["data"]["weights"])
146
+ print(result["data"]["validation"])
147
+ ```
148
+
149
+ ## Configuration
150
+
151
+ ```python
152
+ client = StructOCR(
153
+ api_key="YOUR_API_KEY",
154
+ base_url="https://api.structocr.com/v1",
155
+ timeout=60,
156
+ )
157
+ ```
158
+
159
+ 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.
160
+
161
+ ## Errors
162
+
163
+ API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
164
+
165
+ ```python
166
+ from structocr import StructOCRError
167
+
168
+ try:
169
+ client.scan_passport("./passport.jpg")
170
+ except StructOCRError as error:
171
+ print(error.status_code, error.code, error.retryable)
172
+ ```
173
+
174
+ `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
175
+
176
+ ## License
177
+
178
+ 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="Passport, ID card, driver license, VIN, invoice and receipt OCR: turn images and PDFs into structured JSON. Official StructOCR SDK for Python.",
13
+ keywords=["ocr", "passport ocr", "mrz", "id card ocr", "driver license ocr", "pdf417", "vin ocr", "invoice ocr", "receipt 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
  },
@@ -0,0 +1 @@
1
+ __version__ = "1.7.1"
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: structocr
3
+ Version: 1.7.1
4
+ Summary: Passport, ID card, driver license, VIN, invoice and receipt OCR: turn images and PDFs into structured JSON. Official StructOCR SDK for Python.
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,vin ocr,invoice ocr,receipt 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
+ Send a photo or PDF of a passport, ID card, driver license, VIN, invoice, receipt or shipping container and get structured JSON back: one method call per document, no templates to train.
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 passport or driver license scans, and no credit card is needed.
48
+ 2. Copy your key from **API Keys** in the dashboard.
49
+ 3. Optionally try any document type 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 any document 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
+ | 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) |
61
+ | 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) |
62
+ | 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) |
63
+ | 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) |
64
+ | VIN | `scan_vin` | 1 | [Try it](https://structocr.com/products/vin-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
65
+ | 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) |
66
+ | Invoice | `scan_invoice` | 3 | [Try it](https://structocr.com/products/invoice-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
67
+ | Receipt | `scan_receipt` | 1 | [Try it](https://structocr.com/products/receipt-ocr?utm_source=pypi&utm_medium=readme&utm_campaign=sdk_try#live-demo) |
68
+ | 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) |
69
+ | 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) |
70
+ | ATM cassette | `scan_atm_cassette` | 1 | |
71
+ | 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) |
72
+
73
+ The receipt endpoint's optional enhanced mode costs 2 credits. Only successful requests are charged.
74
+
75
+ ## Install
76
+
77
+ ```bash
78
+ pip install --upgrade structocr
79
+ ```
80
+
81
+ Python 3.7+ is required.
82
+
83
+ ## Quick start
84
+
85
+ ```bash
86
+ export STRUCTOCR_API_KEY="YOUR_API_KEY"
87
+ ```
88
+
89
+ ```python
90
+ from structocr import StructOCR
91
+
92
+ client = StructOCR()
93
+ result = client.scan_passport("./passport.jpg")
94
+
95
+ if result.get("success"):
96
+ data = result["data"]
97
+ print(data.get("passport_number"))
98
+ print(data.get("given_names"), data.get("surname"))
99
+ ```
100
+
101
+ A passport scan returns JSON like this (fictional sample document):
102
+
103
+ ```json
104
+ {
105
+ "success": true,
106
+ "data": {
107
+ "type": "passport",
108
+ "country_code": "UTO",
109
+ "nationality": "UTOPIAN",
110
+ "passport_number": "X4R7T2K9P",
111
+ "surname": "MORGAN",
112
+ "given_names": "OLIVIA ROSE",
113
+ "sex": "F",
114
+ "date_of_birth": "1990-03-14",
115
+ "place_of_birth": "ZENITH CITY",
116
+ "date_of_issue": "2024-07-16",
117
+ "date_of_expiry": "2034-07-15",
118
+ "place_of_issue": null
119
+ }
120
+ }
121
+ ```
122
+
123
+ PDF paths work the same way:
124
+
125
+ ```python
126
+ result = client.scan_invoice("./invoice.pdf")
127
+ ```
128
+
129
+ FastAPI and other server frameworks can pass uploaded bytes without a temporary file:
130
+
131
+ ```python
132
+ content = await upload.read()
133
+ result = client.scan_passport(content)
134
+ ```
135
+
136
+ ## Methods
137
+
138
+ ```text
139
+ scan_passport(file)
140
+ scan_national_id(file)
141
+ scan_driver_license(file)
142
+ scan_driver_license_pdf417(file)
143
+ scan_invoice(file)
144
+ scan_receipt(file)
145
+ scan_vin(file)
146
+ scan_hin(file)
147
+ scan_container(file)
148
+ scan_license_plate(file)
149
+ scan_vehicle_registration(file)
150
+ scan_atm_cassette(file)
151
+ scan_weighbridge_ticket(file)
152
+ get_account_balance()
153
+ ```
154
+
155
+ 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.
156
+
157
+ 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:
158
+
159
+ ```python
160
+ receipt = client.scan_receipt(
161
+ "./receipt.jpg",
162
+ accuracy="enhanced",
163
+ )
164
+ ```
165
+
166
+ `response_version=2` remains accepted for compatibility but is not required. Receipt v1 is retired.
167
+
168
+ US driver license PDF417 example:
169
+
170
+ ```python
171
+ result = client.scan_driver_license_pdf417("./license-back.jpg")
172
+ if result.get("success"):
173
+ print(result["data"]["document_number"])
174
+ ```
175
+
176
+ Weighbridge ticket example:
177
+
178
+ ```python
179
+ result = client.scan_weighbridge_ticket("./weighbridge-ticket.jpg")
180
+ if result.get("success"):
181
+ print(result["data"]["weights"])
182
+ print(result["data"]["validation"])
183
+ ```
184
+
185
+ ## Configuration
186
+
187
+ ```python
188
+ client = StructOCR(
189
+ api_key="YOUR_API_KEY",
190
+ base_url="https://api.structocr.com/v1",
191
+ timeout=60,
192
+ )
193
+ ```
194
+
195
+ 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.
196
+
197
+ ## Errors
198
+
199
+ API and network failures raise `StructOCRError`. Existing `except RuntimeError` code continues to work because `StructOCRError` extends `RuntimeError`.
200
+
201
+ ```python
202
+ from structocr import StructOCRError
203
+
204
+ try:
205
+ client.scan_passport("./passport.jpg")
206
+ except StructOCRError as error:
207
+ print(error.status_code, error.code, error.retryable)
208
+ ```
209
+
210
+ `retryable` is advisory only. The SDK does not automatically retry OCR requests because doing so without an idempotency key could charge a request twice.
211
+
212
+ ## License
213
+
214
+ 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
File without changes