SDKs
Official SDKs are available for TypeScript, Python, and Go. Each SDK wraps the full API surface — document to markdown, document extraction, image transformation, image generation, document generation, and sheet generation — with typed requests and responses.
Installation
npm install iterationlayernpm install iterationlayerpip install iterationlayergo get github.com/iterationlayer/sdk-goQuick Start
curl -X POST \
https://api.iterationlayer.com/document-extraction/v1/extract \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"files": [
{
"type": "url",
"name": "invoice.pdf",
"url": "https://example.com/invoice.pdf"
}
],
"schema": {
"fields": [
{
"name": "vendor",
"type": "TEXT",
"description": "Vendor name"
},
{
"name": "total",
"type": "CURRENCY_AMOUNT",
"description": "Total amount"
}
]
}
}'{
"success": true,
"data": {
"vendor": {
"type": "TEXT",
"value": "Acme Corp",
"confidence": 0.98,
"citations": ["Vendor: Acme Corp"],
"source": "invoice.pdf"
},
"total": {
"type": "CURRENCY_AMOUNT",
"value": 1250.00,
"confidence": 0.95,
"citations": ["Total: €1,250.00"],
"source": "invoice.pdf"
}
}
}import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({
apiKey: "YOUR_API_KEY",
});
const result = await client.extractDocument({
files: [
{
type: "url",
name: "invoice.pdf",
url: "https://example.com/invoice.pdf",
},
],
schema: {
fields: [
{
type: "TEXT",
name: "vendor",
description: "Vendor name",
},
{
type: "CURRENCY_AMOUNT",
name: "total",
description: "Total amount",
},
],
},
});{
"success": true,
"data": {
"vendor": {
"type": "TEXT",
"value": "Acme Corp",
"confidence": 0.98,
"citations": ["Vendor: Acme Corp"],
"source": "invoice.pdf"
},
"total": {
"type": "CURRENCY_AMOUNT",
"value": 1250.00,
"confidence": 0.95,
"citations": ["Total: €1,250.00"],
"source": "invoice.pdf"
}
}
}from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")
result = client.extract_document(
files=[
{
"type": "url",
"name": "invoice.pdf",
"url": "https://example.com/invoice.pdf",
}
],
schema={
"fields": [
{
"type": "TEXT",
"name": "vendor",
"description": "Vendor name",
},
{
"type": "CURRENCY_AMOUNT",
"name": "total",
"description": "Total amount",
},
],
},
){
"success": true,
"data": {
"vendor": {
"type": "TEXT",
"value": "Acme Corp",
"confidence": 0.98,
"citations": ["Vendor: Acme Corp"],
"source": "invoice.pdf"
},
"total": {
"type": "CURRENCY_AMOUNT",
"value": 1250.00,
"confidence": 0.95,
"citations": ["Total: €1,250.00"],
"source": "invoice.pdf"
}
}
}import il "github.com/iterationlayer/sdk-go"
client := il.NewClient("YOUR_API_KEY")
result, err := client.ExtractDocument(il.ExtractDocumentRequest{
Files: []il.FileInput{
{Type: "url", Name: "invoice.pdf", Url: "https://example.com/invoice.pdf"},
},
Schema: il.ExtractionSchema{
Fields: []any{
il.TextFieldConfig{Type: "TEXT", Name: "vendor", Description: "Vendor name"},
il.CurrencyAmountFieldConfig{Type: "CURRENCY_AMOUNT", Name: "total", Description: "Total amount"},
},
},
}){
"success": true,
"data": {
"vendor": {
"type": "TEXT",
"value": "Acme Corp",
"confidence": 0.98,
"citations": ["Vendor: Acme Corp"],
"source": "invoice.pdf"
},
"total": {
"type": "CURRENCY_AMOUNT",
"value": 1250.00,
"confidence": 0.95,
"citations": ["Total: €1,250.00"],
"source": "invoice.pdf"
}
}
}Available SDKs
| Language | Package | Repository |
|---|---|---|
| TypeScript / Node.js | iterationlayer | github.com/iterationlayer/sdk-node |
| Python | iterationlayer | github.com/iterationlayer/sdk-python |
| Go |
github.com/iterationlayer/sdk-go |
github.com/iterationlayer/sdk-go |
API Methods
Each API has a sync method and an async variant for webhook-based processing. Async variants append Async / _async to the method name and require a webhook_url.
| API | TypeScript | Python | Go |
|---|---|---|---|
| Document to Markdown |
convertDocumentToMarkdown |
convert_document_to_markdown |
ConvertDocumentToMarkdown |
| Extraction |
extractDocument |
extract_document |
ExtractDocument |
| Transformation |
transformImage |
transform_image |
TransformImage |
| Image Gen |
generateImage |
generate_image |
GenerateImage |
| Document Gen |
generateDocument |
generate_document |
GenerateDocument |
| Sheet Gen |
generateSheet |
generate_sheet |
GenerateSheet |
Binary Files
The HTTP API still uses base64 strings for inline file inputs and binary outputs. The official SDKs convert those fields to native byte types so application code does not need base64 glue code.
| Language | Inline file input | Binary output |
|---|---|---|
| TypeScript / Node.js |
Uint8Array |
Uint8Array |
| Python |
bytes |
bytes |
| Go |
[]byte |
[]byte |
Configuration
All SDKs accept a custom base URL for self-hosted or staging environments.
# Set the base URL via environment variable or pass it directly
export ITERATION_LAYER_API_KEY="YOUR_API_KEY"import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({
apiKey: "YOUR_API_KEY",
baseUrl: "https://custom.api.example.com",
});from iterationlayer import IterationLayer
client = IterationLayer(
api_key="YOUR_API_KEY",
base_url="https://custom.api.example.com",
)import il "github.com/iterationlayer/sdk-go"
client := il.NewClient(
"YOUR_API_KEY",
il.WithBaseURL("https://custom.api.example.com"),
)Error Handling
All SDKs raise typed errors with the HTTP status code and error message from the API.
# Non-2xx responses return JSON with success: false and an error message
# {
"success": false,
"error": "Validation error: ...",
}import { IterationLayer, IterationLayerError } from "iterationlayer";
const client = new IterationLayer({
apiKey: "YOUR_API_KEY",
});
try {
const result = await client.extractDocument({ /* ... */ });
} catch (error) {
if (error instanceof IterationLayerError) {
// error.statusCode — 422
// error.errorMessage — "Validation error: ..."
}
}from iterationlayer import IterationLayer, IterationLayerError
client = IterationLayer(api_key="YOUR_API_KEY")
try:
result = client.extract_document(files=[...], schema={...})
except IterationLayerError as error:
# error.status_code — 422
# error.error_message — "Validation error: ..."
passimport il "github.com/iterationlayer/sdk-go"
client := il.NewClient("YOUR_API_KEY")
result, err := client.ExtractDocument(il.ExtractDocumentRequest{ /* ... */ })
if err != nil {
var apiErr *il.Error
if errors.As(err, &apiErr) {
fmt.Println(apiErr.StatusCode) // 422
fmt.Println(apiErr.ErrorMessage) // "Validation error: ..."
}
}Async Webhooks
Each method has an async variant (extractAsync, extract_async, ExtractAsync) that accepts a webhook_url. The API returns immediately with an acknowledgment and delivers the result to your webhook endpoint.
curl -X POST \
https://api.iterationlayer.com/document-extraction/v1/extract \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"files": [
{
"type": "url",
"name": "doc.pdf",
"url": "https://example.com/doc.pdf"
}
],
"schema": {
"fields": [
{
"name": "title",
"type": "TEXT",
"description": "Document title"
}
]
},
"webhook_url": "https://your-app.com/webhooks/extraction"
}'const result = await client.extractDocumentAsync({
files: [
{
type: "url",
name: "doc.pdf",
url: "https://example.com/doc.pdf",
},
],
schema: {
fields: [
{
type: "TEXT",
name: "title",
description: "Document title",
},
],
},
webhook_url: "https://your-app.com/webhooks/extraction",
});result = client.extract_document_async(
files=[
{
"type": "url",
"name": "doc.pdf",
"url": "https://example.com/doc.pdf",
}
],
schema={
"fields": [
{
"type": "TEXT",
"name": "title",
"description": "Document title",
}
]
},
webhook_url="https://your-app.com/webhooks/extraction",
)result, err := client.ExtractDocumentAsync(il.ExtractDocumentAsyncRequest{
Files: []il.FileInput{
{Type: "url", Name: "doc.pdf", Url: "https://example.com/doc.pdf"},
},
Schema: il.ExtractionSchema{
Fields: []any{
il.TextFieldConfig{Type: "TEXT", Name: "title", Description: "Document title"},
},
},
WebhookURL: "https://your-app.com/webhooks/extraction",
})
fmt.Println(result.Message) // "Request accepted..."