docs
UAEN
Docs/SDK

Rekognita SDK

Rekognita provides official SDKs for fast integration. Python is currently supported, with plans for Node.js, Go, and Java.

Installation

Install the Python SDK via pip:

pip install rekognita

Or via poetry:

poetry add rekognita

Initialization

Import and initialize the client:

from rekognita import RekognitaClient

client = RekognitaClient(api_key="rk_sk_your_key_here")

# Or use the REKOGNITA_API_KEY environment variable
client = RekognitaClient()  # automatically reads from env

Basic Usage

Converting a Document

# Upload and convert a document
result = client.documents.convert(
    file="invoice.pdf",
    output_format="markdown",  # or "html", "json", "docx"
)

print(result.content)      # Markdown/HTML content
print(result.pages)        # Number of pages
print(result.metadata)     # Document metadata

Extracting Structured Data

# Extract data using a JSON Schema
result = client.documents.extract(
    file="invoice.pdf",
    schema={
        "invoice_number": "string",
        "total_amount": "number",
        "line_items": [{
            "description": "string",
            "quantity": "number",
            "price": "number"
        }]
    }
)

print(result.data)  # {"invoice_number": "INV-2847", ...}

Graph Structure

# Get the graph structure of the document
result = client.documents.parse(
    file="report.pdf",
    output_format="graph",
)

for node in result.nodes:
    print(f"{node.type}: {node.text[:50]}...")
    for child in node.children:
        print(f"  └─ {child.type}: {child.text[:30]}...")

Asynchronous Client

from rekognita import AsyncRekognitaClient

async_client = AsyncRekognitaClient()

result = await async_client.documents.convert(
    file="document.pdf",
    output_format="markdown"
)

Error Handling

from rekognita.exceptions import (
    RekognitaAuthError,
    RekognitaRateLimitError,
    RekognitaValidationError,
)

try:
    result = client.documents.convert(file="doc.pdf")
except RekognitaAuthError:
    print("Invalid API Key")
except RekognitaRateLimitError as e:
    print(f"Rate limit exceeded. Try again in {e.retry_after}s")
except RekognitaValidationError as e:
    print(f"Validation error: {e.message}")

Next Steps