iterationlayer 1.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.
@@ -0,0 +1,24 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ check:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.9", "3.12", "3.13"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+ - run: pip install -e ".[dev]"
21
+ - run: ruff check .
22
+ - run: ruff format --check .
23
+ - run: mypy iterationlayer
24
+ - run: pytest
@@ -0,0 +1,21 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.13"
16
+ - run: pip install build twine
17
+ - run: python -m build
18
+ - run: twine upload dist/*
19
+ env:
20
+ TWINE_USERNAME: __token__
21
+ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ .pytest_cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Iteration Layer
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,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: iterationlayer
3
+ Version: 1.1.0
4
+ Summary: Official Python SDK for the Iteration Layer API
5
+ Project-URL: Homepage, https://iterationlayer.com
6
+ Project-URL: Documentation, https://iterationlayer.com/docs
7
+ Project-URL: Repository, https://github.com/iterationlayer/sdk-python
8
+ Project-URL: Issues, https://github.com/iterationlayer/issues
9
+ Author: Iteration Layer
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: api,document-extraction,document-generation,image-generation,image-transformation,iteration-layer,sdk
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Requires-Python: >=3.9
17
+ Requires-Dist: httpx<1,>=0.27
18
+ Provides-Extra: dev
19
+ Requires-Dist: mypy>=1.15; extra == 'dev'
20
+ Requires-Dist: pytest>=8.0; extra == 'dev'
21
+ Requires-Dist: respx>=0.22; extra == 'dev'
22
+ Requires-Dist: ruff>=0.11; extra == 'dev'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Iteration Layer Python SDK
26
+
27
+ Official Python SDK for the [Iteration Layer API](https://iterationlayer.com).
28
+
29
+ ## Installation
30
+
31
+ ```sh
32
+ pip install iterationlayer
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ```python
38
+ from iterationlayer import IterationLayer
39
+
40
+ client = IterationLayer(api_key="il_your_api_key")
41
+ ```
42
+
43
+ ### Document Extraction
44
+
45
+ Extract structured data from documents using AI.
46
+
47
+ ```python
48
+ result = client.extract(
49
+ files=[{"type": "url", "name": "invoice.pdf", "url": "https://example.com/invoice.pdf"}],
50
+ schema={
51
+ "fields": [
52
+ {"type": "TEXT", "name": "company_name", "description": "The company name"},
53
+ {"type": "CURRENCY_AMOUNT", "name": "total", "description": "The invoice total"},
54
+ ]
55
+ },
56
+ )
57
+
58
+ print(result["company_name"]["value"]) # "Acme Corp"
59
+ print(result["company_name"]["confidence"]) # 0.95
60
+ ```
61
+
62
+ ### Image Transformation
63
+
64
+ Resize, crop, convert, and apply effects to images.
65
+
66
+ ```python
67
+ result = client.transform(
68
+ file={"type": "url", "name": "photo.jpg", "url": "https://example.com/photo.jpg"},
69
+ operations=[
70
+ {"type": "resize", "width_in_px": 800, "height_in_px": 600, "fit": "cover"},
71
+ {"type": "convert", "format": "webp", "quality": 85},
72
+ ],
73
+ )
74
+
75
+ import base64
76
+ image_bytes = base64.b64decode(result["buffer"])
77
+ ```
78
+
79
+ ### Image Generation
80
+
81
+ Compose images from layer definitions.
82
+
83
+ ```python
84
+ result = client.generate_image(
85
+ dimensions={"width_in_px": 1200, "height_in_px": 630},
86
+ layers=[
87
+ {"type": "solid-color", "index": 0, "hex_color": "#1a1a2e"},
88
+ {
89
+ "type": "text",
90
+ "index": 1,
91
+ "text": "Hello World",
92
+ "font_name": "Inter",
93
+ "font_size_in_px": 48,
94
+ "text_color": "#ffffff",
95
+ "position": {"x_in_px": 50, "y_in_px": 50},
96
+ "dimensions": {"width_in_px": 1100, "height_in_px": 530},
97
+ },
98
+ ],
99
+ output_format="png",
100
+ )
101
+
102
+ import base64
103
+ image_bytes = base64.b64decode(result["buffer"])
104
+ ```
105
+
106
+ ### Document Generation
107
+
108
+ Generate PDF, DOCX, EPUB, or PPTX from structured data.
109
+
110
+ ```python
111
+ result = client.generate_document(
112
+ format="pdf",
113
+ document={
114
+ "metadata": {"title": "Invoice #123"},
115
+ "page": {
116
+ "size": {"preset": "A4"},
117
+ "margins": {"top_in_pt": 36, "bottom_in_pt": 36, "left_in_pt": 36, "right_in_pt": 36},
118
+ },
119
+ "styles": {
120
+ "text": {"font_family": "Helvetica", "font_size_in_pt": 12, "line_height": 1.5, "color": "#000000"},
121
+ "headline": {"font_family": "Helvetica", "font_size_in_pt": 24, "color": "#000000", "spacing_before_in_pt": 12, "spacing_after_in_pt": 6},
122
+ "link": {"color": "#0066cc"},
123
+ "list": {"indent_in_pt": 18, "spacing_between_items_in_pt": 4},
124
+ "table": {
125
+ "header": {"background_color": "#f0f0f0", "font_family": "Helvetica", "font_size_in_pt": 12, "color": "#000000", "padding_in_pt": 6},
126
+ "body": {"font_family": "Helvetica", "font_size_in_pt": 12, "color": "#000000", "padding_in_pt": 6},
127
+ },
128
+ "grid": {"gap_in_pt": 12},
129
+ "separator": {"color": "#cccccc", "thickness_in_pt": 1, "margin_top_in_pt": 12, "margin_bottom_in_pt": 12},
130
+ "image": {"alignment": "center", "margin_top_in_pt": 8, "margin_bottom_in_pt": 8},
131
+ },
132
+ "content": [
133
+ {"type": "headline", "level": "h1", "text": "Invoice #123"},
134
+ {"type": "paragraph", "markdown": "Thank you for your business."},
135
+ ],
136
+ },
137
+ )
138
+
139
+ import base64
140
+ pdf_bytes = base64.b64decode(result["buffer"])
141
+ ```
142
+
143
+ ### Sheet Generation
144
+
145
+ Generate CSV, Markdown, or XLSX spreadsheets from structured data.
146
+
147
+ ```python
148
+ result = client.generate_sheet(
149
+ format="xlsx",
150
+ sheets=[
151
+ {
152
+ "name": "Invoices",
153
+ "columns": [
154
+ {"name": "Company", "width": 20},
155
+ {"name": "Total", "width": 15},
156
+ ],
157
+ "rows": [
158
+ [
159
+ {"value": "Acme Corp"},
160
+ {"value": 1500.50, "format": "currency", "currency_code": "EUR"},
161
+ ],
162
+ ],
163
+ },
164
+ ],
165
+ )
166
+
167
+ import base64
168
+ sheet_bytes = base64.b64decode(result["buffer"])
169
+ ```
170
+
171
+ ### Webhooks (Async)
172
+
173
+ Use the `*_async` methods to receive results via webhook instead of waiting for the response.
174
+
175
+ ```python
176
+ result = client.extract_async(
177
+ files=[{"type": "url", "name": "invoice.pdf", "url": "https://example.com/invoice.pdf"}],
178
+ schema={
179
+ "fields": [
180
+ {"type": "CURRENCY_AMOUNT", "name": "total", "description": "The invoice total"},
181
+ ]
182
+ },
183
+ webhook_url="https://your-app.com/webhooks/extraction",
184
+ )
185
+ ```
186
+
187
+ ### Context Manager
188
+
189
+ The client can be used as a context manager to ensure the underlying HTTP connection is closed.
190
+
191
+ ```python
192
+ with IterationLayer(api_key="il_your_api_key") as client:
193
+ result = client.extract(...)
194
+ ```
195
+
196
+ ### Error Handling
197
+
198
+ ```python
199
+ from iterationlayer import IterationLayerError
200
+
201
+ try:
202
+ result = client.extract(...)
203
+ except IterationLayerError as e:
204
+ print(e.status_code) # 422
205
+ print(e.error_message) # "Validation error: ..."
206
+ ```
207
+
208
+ ## Documentation
209
+
210
+ Full documentation is available at [https://iterationlayer.com/docs](https://iterationlayer.com/docs).
211
+
212
+ ## Issues & Feedback
213
+
214
+ Please report bugs and request features in the [issues repository](https://github.com/iterationlayer/issues).
@@ -0,0 +1,190 @@
1
+ # Iteration Layer Python SDK
2
+
3
+ Official Python SDK for the [Iteration Layer API](https://iterationlayer.com).
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pip install iterationlayer
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from iterationlayer import IterationLayer
15
+
16
+ client = IterationLayer(api_key="il_your_api_key")
17
+ ```
18
+
19
+ ### Document Extraction
20
+
21
+ Extract structured data from documents using AI.
22
+
23
+ ```python
24
+ result = client.extract(
25
+ files=[{"type": "url", "name": "invoice.pdf", "url": "https://example.com/invoice.pdf"}],
26
+ schema={
27
+ "fields": [
28
+ {"type": "TEXT", "name": "company_name", "description": "The company name"},
29
+ {"type": "CURRENCY_AMOUNT", "name": "total", "description": "The invoice total"},
30
+ ]
31
+ },
32
+ )
33
+
34
+ print(result["company_name"]["value"]) # "Acme Corp"
35
+ print(result["company_name"]["confidence"]) # 0.95
36
+ ```
37
+
38
+ ### Image Transformation
39
+
40
+ Resize, crop, convert, and apply effects to images.
41
+
42
+ ```python
43
+ result = client.transform(
44
+ file={"type": "url", "name": "photo.jpg", "url": "https://example.com/photo.jpg"},
45
+ operations=[
46
+ {"type": "resize", "width_in_px": 800, "height_in_px": 600, "fit": "cover"},
47
+ {"type": "convert", "format": "webp", "quality": 85},
48
+ ],
49
+ )
50
+
51
+ import base64
52
+ image_bytes = base64.b64decode(result["buffer"])
53
+ ```
54
+
55
+ ### Image Generation
56
+
57
+ Compose images from layer definitions.
58
+
59
+ ```python
60
+ result = client.generate_image(
61
+ dimensions={"width_in_px": 1200, "height_in_px": 630},
62
+ layers=[
63
+ {"type": "solid-color", "index": 0, "hex_color": "#1a1a2e"},
64
+ {
65
+ "type": "text",
66
+ "index": 1,
67
+ "text": "Hello World",
68
+ "font_name": "Inter",
69
+ "font_size_in_px": 48,
70
+ "text_color": "#ffffff",
71
+ "position": {"x_in_px": 50, "y_in_px": 50},
72
+ "dimensions": {"width_in_px": 1100, "height_in_px": 530},
73
+ },
74
+ ],
75
+ output_format="png",
76
+ )
77
+
78
+ import base64
79
+ image_bytes = base64.b64decode(result["buffer"])
80
+ ```
81
+
82
+ ### Document Generation
83
+
84
+ Generate PDF, DOCX, EPUB, or PPTX from structured data.
85
+
86
+ ```python
87
+ result = client.generate_document(
88
+ format="pdf",
89
+ document={
90
+ "metadata": {"title": "Invoice #123"},
91
+ "page": {
92
+ "size": {"preset": "A4"},
93
+ "margins": {"top_in_pt": 36, "bottom_in_pt": 36, "left_in_pt": 36, "right_in_pt": 36},
94
+ },
95
+ "styles": {
96
+ "text": {"font_family": "Helvetica", "font_size_in_pt": 12, "line_height": 1.5, "color": "#000000"},
97
+ "headline": {"font_family": "Helvetica", "font_size_in_pt": 24, "color": "#000000", "spacing_before_in_pt": 12, "spacing_after_in_pt": 6},
98
+ "link": {"color": "#0066cc"},
99
+ "list": {"indent_in_pt": 18, "spacing_between_items_in_pt": 4},
100
+ "table": {
101
+ "header": {"background_color": "#f0f0f0", "font_family": "Helvetica", "font_size_in_pt": 12, "color": "#000000", "padding_in_pt": 6},
102
+ "body": {"font_family": "Helvetica", "font_size_in_pt": 12, "color": "#000000", "padding_in_pt": 6},
103
+ },
104
+ "grid": {"gap_in_pt": 12},
105
+ "separator": {"color": "#cccccc", "thickness_in_pt": 1, "margin_top_in_pt": 12, "margin_bottom_in_pt": 12},
106
+ "image": {"alignment": "center", "margin_top_in_pt": 8, "margin_bottom_in_pt": 8},
107
+ },
108
+ "content": [
109
+ {"type": "headline", "level": "h1", "text": "Invoice #123"},
110
+ {"type": "paragraph", "markdown": "Thank you for your business."},
111
+ ],
112
+ },
113
+ )
114
+
115
+ import base64
116
+ pdf_bytes = base64.b64decode(result["buffer"])
117
+ ```
118
+
119
+ ### Sheet Generation
120
+
121
+ Generate CSV, Markdown, or XLSX spreadsheets from structured data.
122
+
123
+ ```python
124
+ result = client.generate_sheet(
125
+ format="xlsx",
126
+ sheets=[
127
+ {
128
+ "name": "Invoices",
129
+ "columns": [
130
+ {"name": "Company", "width": 20},
131
+ {"name": "Total", "width": 15},
132
+ ],
133
+ "rows": [
134
+ [
135
+ {"value": "Acme Corp"},
136
+ {"value": 1500.50, "format": "currency", "currency_code": "EUR"},
137
+ ],
138
+ ],
139
+ },
140
+ ],
141
+ )
142
+
143
+ import base64
144
+ sheet_bytes = base64.b64decode(result["buffer"])
145
+ ```
146
+
147
+ ### Webhooks (Async)
148
+
149
+ Use the `*_async` methods to receive results via webhook instead of waiting for the response.
150
+
151
+ ```python
152
+ result = client.extract_async(
153
+ files=[{"type": "url", "name": "invoice.pdf", "url": "https://example.com/invoice.pdf"}],
154
+ schema={
155
+ "fields": [
156
+ {"type": "CURRENCY_AMOUNT", "name": "total", "description": "The invoice total"},
157
+ ]
158
+ },
159
+ webhook_url="https://your-app.com/webhooks/extraction",
160
+ )
161
+ ```
162
+
163
+ ### Context Manager
164
+
165
+ The client can be used as a context manager to ensure the underlying HTTP connection is closed.
166
+
167
+ ```python
168
+ with IterationLayer(api_key="il_your_api_key") as client:
169
+ result = client.extract(...)
170
+ ```
171
+
172
+ ### Error Handling
173
+
174
+ ```python
175
+ from iterationlayer import IterationLayerError
176
+
177
+ try:
178
+ result = client.extract(...)
179
+ except IterationLayerError as e:
180
+ print(e.status_code) # 422
181
+ print(e.error_message) # "Validation error: ..."
182
+ ```
183
+
184
+ ## Documentation
185
+
186
+ Full documentation is available at [https://iterationlayer.com/docs](https://iterationlayer.com/docs).
187
+
188
+ ## Issues & Feedback
189
+
190
+ Please report bugs and request features in the [issues repository](https://github.com/iterationlayer/issues).
@@ -0,0 +1,10 @@
1
+ from iterationlayer.client import (
2
+ IterationLayer,
3
+ IterationLayerError,
4
+ )
5
+ from iterationlayer.types import * # noqa: F401, F403
6
+
7
+ __all__ = [
8
+ "IterationLayer",
9
+ "IterationLayerError",
10
+ ]