invoicedataextraction-sdk 0.1.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.
- invoicedataextraction_sdk-0.1.0/LICENSE +21 -0
- invoicedataextraction_sdk-0.1.0/PKG-INFO +108 -0
- invoicedataextraction_sdk-0.1.0/README.md +92 -0
- invoicedataextraction_sdk-0.1.0/pyproject.toml +30 -0
- invoicedataextraction_sdk-0.1.0/setup.cfg +4 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction/__init__.py +3 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction/client.py +924 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction/errors.py +73 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction/http.py +93 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction/local_files.py +165 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction/utils.py +11 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction/validation.py +191 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction_sdk.egg-info/PKG-INFO +108 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction_sdk.egg-info/SOURCES.txt +15 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction_sdk.egg-info/dependency_links.txt +1 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction_sdk.egg-info/requires.txt +4 -0
- invoicedataextraction_sdk-0.1.0/src/invoicedataextraction_sdk.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Invoice Data Extraction
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: invoicedataextraction-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for Invoice Data Extraction.
|
|
5
|
+
Author-email: Invoice Data Extraction <developers@invoicedataextraction.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://invoicedataextraction.com
|
|
8
|
+
Project-URL: Documentation, https://invoicedataextraction.com/docs
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: requests>=2.28.0
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# invoicedataextraction-sdk
|
|
18
|
+
|
|
19
|
+
Official Python SDK for [Invoice Data Extraction](https://invoicedataextraction.com). Handles file upload, extraction submission, polling, and result download so you can go from local files to structured output in a few lines of code.
|
|
20
|
+
|
|
21
|
+
- Python 3.9 or later
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install invoicedataextraction-sdk
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import os
|
|
33
|
+
from invoicedataextraction import InvoiceDataExtraction
|
|
34
|
+
|
|
35
|
+
client = InvoiceDataExtraction(
|
|
36
|
+
api_key=os.environ["INVOICE_DATA_EXTRACTION_API_KEY"],
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
result = client.extract(
|
|
40
|
+
folder_path="./invoices",
|
|
41
|
+
prompt="Extract invoice number and total",
|
|
42
|
+
output_structure="per_invoice",
|
|
43
|
+
download={
|
|
44
|
+
"formats": ["xlsx", "json"],
|
|
45
|
+
"output_path": "./output",
|
|
46
|
+
},
|
|
47
|
+
console_output=True, # remove to disable console logging
|
|
48
|
+
)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`extract(...)` uploads your files (pass a `folder_path` or a list of `files`), submits the extraction, polls until it finishes, and downloads the results. The returned `result` is the final polling response from the API. Check `result["pages"]["failed_count"]` to verify that all uploaded pages were processed successfully.
|
|
52
|
+
|
|
53
|
+
Generate an API key from your [dashboard](https://invoicedataextraction.com/dashboard?view=API). Every account includes 50 free pages per month. Additional credits can be purchased on a pay-as-you-go basis with no subscription needed.
|
|
54
|
+
|
|
55
|
+
## Staged Workflow
|
|
56
|
+
|
|
57
|
+
If you need control over individual steps — for example, uploading files in one part of your system and extracting in another — use the lower-level methods:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
upload = client.upload_files(
|
|
61
|
+
files=["./invoice1.pdf", "./invoice2.pdf"],
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
submitted = client.submit_extraction(
|
|
65
|
+
upload_session_id=upload["upload_session_id"],
|
|
66
|
+
file_ids=upload["file_ids"],
|
|
67
|
+
prompt="Extract invoice number and total",
|
|
68
|
+
output_structure="per_invoice",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
result = client.wait_for_extraction_to_finish(
|
|
72
|
+
extraction_id=submitted["extraction_id"],
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
client.download_output(
|
|
76
|
+
extraction_id=submitted["extraction_id"],
|
|
77
|
+
format="xlsx",
|
|
78
|
+
file_path="./output/invoices.xlsx",
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Error Handling
|
|
83
|
+
|
|
84
|
+
SDK methods raise exceptions on failure. The structured error body is on `error.body`:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from invoicedataextraction import InvoiceDataExtraction
|
|
88
|
+
from invoicedataextraction.errors import SdkError, ApiResponseError
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
client.extract(...)
|
|
92
|
+
except (SdkError, ApiResponseError) as error:
|
|
93
|
+
print(error.body["error"]["code"]) # e.g. "INVALID_INPUT"
|
|
94
|
+
print(error.body["error"]["message"]) # Human-readable message
|
|
95
|
+
print(error.body["error"]["retryable"])
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
When an extraction task itself fails (e.g. insufficient credits), `extract(...)` returns the failed response rather than raising — check `result["status"]` for `"completed"` or `"failed"`.
|
|
99
|
+
|
|
100
|
+
## Documentation
|
|
101
|
+
|
|
102
|
+
- [Python SDK docs](https://invoicedataextraction.com/sdk/python) — full method reference, parameters, return shapes, and examples
|
|
103
|
+
- [REST API docs](https://invoicedataextraction.com/api) — endpoint-level documentation for direct HTTP integration
|
|
104
|
+
- [Dashboard](https://invoicedataextraction.com/dashboard?view=API) — manage API keys and view extraction results
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# invoicedataextraction-sdk
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [Invoice Data Extraction](https://invoicedataextraction.com). Handles file upload, extraction submission, polling, and result download so you can go from local files to structured output in a few lines of code.
|
|
4
|
+
|
|
5
|
+
- Python 3.9 or later
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install invoicedataextraction-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import os
|
|
17
|
+
from invoicedataextraction import InvoiceDataExtraction
|
|
18
|
+
|
|
19
|
+
client = InvoiceDataExtraction(
|
|
20
|
+
api_key=os.environ["INVOICE_DATA_EXTRACTION_API_KEY"],
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
result = client.extract(
|
|
24
|
+
folder_path="./invoices",
|
|
25
|
+
prompt="Extract invoice number and total",
|
|
26
|
+
output_structure="per_invoice",
|
|
27
|
+
download={
|
|
28
|
+
"formats": ["xlsx", "json"],
|
|
29
|
+
"output_path": "./output",
|
|
30
|
+
},
|
|
31
|
+
console_output=True, # remove to disable console logging
|
|
32
|
+
)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`extract(...)` uploads your files (pass a `folder_path` or a list of `files`), submits the extraction, polls until it finishes, and downloads the results. The returned `result` is the final polling response from the API. Check `result["pages"]["failed_count"]` to verify that all uploaded pages were processed successfully.
|
|
36
|
+
|
|
37
|
+
Generate an API key from your [dashboard](https://invoicedataextraction.com/dashboard?view=API). Every account includes 50 free pages per month. Additional credits can be purchased on a pay-as-you-go basis with no subscription needed.
|
|
38
|
+
|
|
39
|
+
## Staged Workflow
|
|
40
|
+
|
|
41
|
+
If you need control over individual steps — for example, uploading files in one part of your system and extracting in another — use the lower-level methods:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
upload = client.upload_files(
|
|
45
|
+
files=["./invoice1.pdf", "./invoice2.pdf"],
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
submitted = client.submit_extraction(
|
|
49
|
+
upload_session_id=upload["upload_session_id"],
|
|
50
|
+
file_ids=upload["file_ids"],
|
|
51
|
+
prompt="Extract invoice number and total",
|
|
52
|
+
output_structure="per_invoice",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
result = client.wait_for_extraction_to_finish(
|
|
56
|
+
extraction_id=submitted["extraction_id"],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
client.download_output(
|
|
60
|
+
extraction_id=submitted["extraction_id"],
|
|
61
|
+
format="xlsx",
|
|
62
|
+
file_path="./output/invoices.xlsx",
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Error Handling
|
|
67
|
+
|
|
68
|
+
SDK methods raise exceptions on failure. The structured error body is on `error.body`:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from invoicedataextraction import InvoiceDataExtraction
|
|
72
|
+
from invoicedataextraction.errors import SdkError, ApiResponseError
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
client.extract(...)
|
|
76
|
+
except (SdkError, ApiResponseError) as error:
|
|
77
|
+
print(error.body["error"]["code"]) # e.g. "INVALID_INPUT"
|
|
78
|
+
print(error.body["error"]["message"]) # Human-readable message
|
|
79
|
+
print(error.body["error"]["retryable"])
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When an extraction task itself fails (e.g. insufficient credits), `extract(...)` returns the failed response rather than raising — check `result["status"]` for `"completed"` or `"failed"`.
|
|
83
|
+
|
|
84
|
+
## Documentation
|
|
85
|
+
|
|
86
|
+
- [Python SDK docs](https://invoicedataextraction.com/sdk/python) — full method reference, parameters, return shapes, and examples
|
|
87
|
+
- [REST API docs](https://invoicedataextraction.com/api) — endpoint-level documentation for direct HTTP integration
|
|
88
|
+
- [Dashboard](https://invoicedataextraction.com/dashboard?view=API) — manage API keys and view extraction results
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "invoicedataextraction-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for Invoice Data Extraction."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Invoice Data Extraction", email = "developers@invoicedataextraction.com" },
|
|
12
|
+
]
|
|
13
|
+
license = "MIT"
|
|
14
|
+
requires-python = ">=3.9"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"requests>=2.28.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
dev = [
|
|
21
|
+
"pytest>=7.0",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[tool.pytest.ini_options]
|
|
25
|
+
testpaths = ["tests"]
|
|
26
|
+
pythonpath = ["src"]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://invoicedataextraction.com"
|
|
30
|
+
Documentation = "https://invoicedataextraction.com/docs"
|