This project has been archived by its maintainers, and is no longer receiving any updates.
Iteration Layer Python SDK
Official Python SDK for the Iteration Layer API.
Installation
pip install iterationlayer
Usage
from iterationlayer import IterationLayer
client = IterationLayer(api_key="il_your_api_key")
Document Extraction
Extract structured data from documents using AI.
result = client.extract_document(
files=[{"type": "url", "name": "invoice.pdf", "url": "https://example.com/invoice.pdf"}],
schema={
"fields": [
{"type": "TEXT", "name": "company_name", "description": "The company name"},
{"type": "CURRENCY_AMOUNT", "name": "total", "description": "The invoice total"},
]
},
)
print(result["company_name"]["value"]) # "Acme Corp"
print(result["company_name"]["confidence"]) # 0.95
Website Extraction
Extract structured data from public website pages. Static fetching is used by default; set should_render_javascript when a page needs browser rendering.
result = client.extract_website(
file={
"type": "url",
"url": "https://example.com/pricing",
"fetch_options": {"should_render_javascript": True},
},
schema={
"fields": [
{"type": "TEXT", "name": "plan_name", "description": "The pricing plan name"},
{"type": "CURRENCY_AMOUNT", "name": "price", "description": "The monthly price"},
]
},
)
print(result["plan_name"]["value"]) # "Pro"
Image Transformation
Resize, crop, convert, and apply effects to images.
result = client.transform_image(
file={"type": "url", "name": "photo.jpg", "url": "https://example.com/photo.jpg"},
operations=[
{"type": "resize", "width_in_px": 800, "height_in_px": 600, "fit": "cover"},
{"type": "convert", "format": "webp", "quality": 85},
],
)
import base64
image_bytes = base64.b64decode(result["buffer"])
Image Generation
Compose images from layer definitions.
result = client.generate_image(
dimensions={"width_in_px": 1200, "height_in_px": 630},
layers=[
{"type": "solid-color", "index": 0, "hex_color": "#1a1a2e"},
{
"type": "text",
"index": 1,
"text": "Hello World",
"font_name": "Inter",
"font_size_in_px": 48,
"text_color": "#ffffff",
"position": {"x_in_px": 50, "y_in_px": 50},
"dimensions": {"width_in_px": 1100, "height_in_px": 530},
},
],
output_format="png",
)
import base64
image_bytes = base64.b64decode(result["buffer"])
Document Generation
Generate PDF, DOCX, EPUB, or PPTX from structured data.
result = client.generate_document(
format="pdf",
document={
"metadata": {"title": "Invoice #123"},
"page": {
"size": {"preset": "A4"},
"margins": {"top_in_pt": 36, "bottom_in_pt": 36, "left_in_pt": 36, "right_in_pt": 36},
},
"styles": {
"text": {"font_family": "Helvetica", "font_size_in_pt": 12, "line_height": 1.5, "color": "#000000"},
"headline": {"font_family": "Helvetica", "font_size_in_pt": 24, "color": "#000000", "spacing_before_in_pt": 12, "spacing_after_in_pt": 6},
"link": {"color": "#0066cc"},
"list": {"indent_in_pt": 18, "spacing_between_items_in_pt": 4},
"table": {
"header": {"background_color": "#f0f0f0", "font_family": "Helvetica", "font_size_in_pt": 12, "color": "#000000", "padding_in_pt": 6},
"body": {"font_family": "Helvetica", "font_size_in_pt": 12, "color": "#000000", "padding_in_pt": 6},
},
"grid": {"gap_in_pt": 12},
"separator": {"color": "#cccccc", "thickness_in_pt": 1, "margin_top_in_pt": 12, "margin_bottom_in_pt": 12},
"image": {"alignment": "center", "margin_top_in_pt": 8, "margin_bottom_in_pt": 8},
},
"content": [
{"type": "headline", "level": "h1", "text": "Invoice #123"},
{"type": "paragraph", "markdown": "Thank you for your business."},
],
},
)
import base64
pdf_bytes = base64.b64decode(result["buffer"])
Sheet Generation
Generate CSV, Markdown, or XLSX spreadsheets from structured data.
result = client.generate_sheet(
format="xlsx",
sheets=[
{
"name": "Invoices",
"columns": [
{"name": "Company", "width": 20},
{"name": "Total", "width": 15},
],
"rows": [
[
{"value": "Acme Corp"},
{"value": 1500.50, "format": "currency", "currency_code": "EUR"},
],
],
},
],
)
import base64
sheet_bytes = base64.b64decode(result["buffer"])
Webhooks (Async)
Use the *_async methods to receive results via webhook instead of waiting for the response.
result = client.extract_document_async(
files=[{"type": "url", "name": "invoice.pdf", "url": "https://example.com/invoice.pdf"}],
schema={
"fields": [
{"type": "CURRENCY_AMOUNT", "name": "total", "description": "The invoice total"},
]
},
webhook_url="https://your-app.com/webhooks/extraction",
)
Context Manager
The client can be used as a context manager to ensure the underlying HTTP connection is closed.
with IterationLayer(api_key="il_your_api_key") as client:
result = client.extract_document(...)
Error Handling
from iterationlayer import IterationLayerError
try:
result = client.extract_document(...)
except IterationLayerError as e:
print(e.status_code) # 422
print(e.error_message) # "Validation error: ..."
Documentation
Full documentation is available at https://iterationlayer.com/docs.
Issues & Feedback
Please report bugs and request features in the issues repository.
Metadata
Release files for iterationlayer 2.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| iterationlayer-2.0.5.tar.gz | 17.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| iterationlayer-2.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.1 kB
Release files / iterationlayer-2.0.5.tar.gz
| Download URL | iterationlayer-2.0.5.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9809d7284f2658a03c2d5d049be8ef32eaee2f860b2f65372ec9c66ad6176a0c
|
|
BLAKE2b-256 checksum How to use checksums |
dae0f964792938d5d04b834570aeeb07887c8bf6b8933fea342af360b7e786e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2026.
Transparency logRelease files / iterationlayer-2.0.5-py3-none-any.whl
| Download URL | iterationlayer-2.0.5-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6de2f74043c76a38056f8a0d10ebc9186ad0405c7d76bc886471341594a61c5b
|
|
BLAKE2b-256 checksum How to use checksums |
ec7fda2f5a7c28cec3fc4d2207158c568b2ee7ad935e7746c377a2e46e7d9127
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2026.
Transparency log