SDKs

Official SDKs are available for TypeScript, Python, and Go. Each SDK wraps the full API surface — document extraction, image transformation, image generation, and document generation — with typed requests and responses.

Installation

npm install iterationlayer
npm install iterationlayer
pip install iterationlayer
go get github.com/iterationlayer/sdk-go

Quick 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"}
      ]
    }
  }'
import { IterationLayer } from "iterationlayer";

const client = new IterationLayer({ apiKey: "YOUR_API_KEY" });

const result = await client.extract({
  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" },
    ],
  },
});
from iterationlayer import IterationLayer

client = IterationLayer(api_key="YOUR_API_KEY")

result = client.extract(
    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"},
        ],
    },
)
import il "github.com/iterationlayer/sdk-go"

client := il.NewClient("YOUR_API_KEY")

result, err := client.Extract(il.ExtractRequest{
    Files: []il.FileInput{
        il.NewFileFromURL("invoice.pdf", "https://example.com/invoice.pdf"),
    },
    Schema: il.ExtractionSchema{
        "vendor": il.NewTextFieldConfig("vendor", "Vendor name"),
        "total":  il.NewCurrencyAmountFieldConfig("total", "Total amount"),
    },
})

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

All SDKs expose four sync methods (one per API) and four async variants for webhook-based processing. Async variants append Async / _async to the method name and require a webhook_url.

API TypeScript Python Go
Extraction extract extract Extract
Transformation transform transform Transform
Image Gen generateImage generate_image GenerateImage
Document Gen generateDocument generate_document GenerateDocument

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.extract({ /* ... */ });
} catch (error) {
  if (error instanceof IterationLayerError) {
    console.log(error.statusCode);    // 422
    console.log(error.errorMessage);  // "Validation error: ..."
  }
}
from iterationlayer import IterationLayer, IterationLayerError

client = IterationLayer(api_key="YOUR_API_KEY")

try:
    result = client.extract(files=[...], schema={...})
except IterationLayerError as error:
    print(error.status_code)    # 422
    print(error.error_message)  # "Validation error: ..."
import (
    "errors"
    il "github.com/iterationlayer/sdk-go"
)

client := il.NewClient("YOUR_API_KEY")

result, err := client.Extract(il.ExtractRequest{ /* ... */ })
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.extractAsync({
  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",
});

console.log(result.message); // "Request accepted..."
result = client.extract_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.ExtractAsync(il.ExtractAsyncRequest{
    Files: []il.FileInput{
        il.NewFileFromURL("doc.pdf", "https://example.com/doc.pdf"),
    },
    Schema: il.ExtractionSchema{
        "title": il.NewTextFieldConfig("title", "Document title"),
    },
    WebhookURL: "https://your-app.com/webhooks/extraction",
})

fmt.Println(result.Message) // "Request accepted..."