Iteration Layer

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 iterationlayer
npm install iterationlayer
pip install iterationlayer
go get github.com/iterationlayer/sdk-go

Quick Start

Request
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"
        }
      ]
    }
  }'
Response
{
  "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"
    }
  }
}
Request
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",
      },
    ],
  },
});
Response
{
  "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"
    }
  }
}
Request
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",
            },
        ],
    },
)
Response
{
  "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"
    }
  }
}
Request
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"),
    },
})
Response
{
  "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 convertToMarkdown convert_to_markdown ConvertToMarkdown
Extraction extract extract Extract
Transformation transform transform Transform
Image Gen generateImage generate_image GenerateImage
Document Gen generateDocument generate_document GenerateDocument
Sheet Gen generateSheet generate_sheet GenerateSheet

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) {
    // error.statusCode — 422
    // 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:
    # error.status_code — 422
    # error.error_message — "Validation error: ..."
    pass
import 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",
});
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..."