Skip to content

Document Intelligence

Extract text, tables, forms, and structured data from documents and images using AI-powered OCR and document analysis.

FeatureEndpointCreditsDescription
OCRPOST /v1/ai/document/detect-text1Simple text extraction
AnalyzePOST /v1/ai/document/analyze3Tables + forms + key-value pairs
ExpensePOST /v1/ai/document/analyze-expense5Invoice/receipt structured extraction

Supported formats: PDF, JPEG, PNG, TIFF (max 10MB per document).


Detect Text (OCR)

Simple, fast text extraction from images and documents.

Endpoint

POST /v1/ai/document/detect-text

Billing: 1 credit per page

Parameters

ParameterTypeRequiredDescription
documentstringYesBase64-encoded document (PDF/image). Max 10MB.

Response

json
{
  "text": "FOTOhub Invoice #2026-07-001\nDate: 2026-07-19\nCustomer: Jan Kowalski",
  "lines": [
    { "text": "FOTOhub Invoice #2026-07-001", "confidence": 99.8 },
    { "text": "Date: 2026-07-19", "confidence": 99.5 }
  ],
  "total_lines": 6,
  "credits_used": 1
}

Example

python
import base64
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_...")

with open("document.png", "rb") as f:
    doc_b64 = base64.b64encode(f.read()).decode()

result = client.document.detect_text(document=doc_b64)
print(result.text)
bash
curl -X POST "https://apis.fotohub.app/v1/ai/document/detect-text" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "document": "BASE64_ENCODED_IMAGE..."
  }'

Analyze Document

Advanced analysis with table extraction, form fields (key-value pairs), and structural layout detection.

Endpoint

POST /v1/ai/document/analyze

Billing: 3 credits per page

Parameters

ParameterTypeRequiredDefaultDescription
documentstringYesBase64-encoded document. Max 10MB.
featuresarrayNo["TABLES", "FORMS"]Features to extract: "TABLES", "FORMS", "SIGNATURES", "LAYOUT".

Response

json
{
  "text": "Full text content of the document...",
  "lines": [
    { "text": "Line content", "confidence": 99.2 }
  ],
  "tables": [
    [
      ["Item", "Qty", "Price"],
      ["AI Credits 1000", "1", "49.99 PLN"],
      ["Storage 100GB", "1", "29.99 PLN"]
    ]
  ],
  "key_values": [
    { "key": "Invoice Number", "value": "FH-2026-001" },
    { "key": "Date", "value": "2026-07-19" },
    { "key": "Customer", "value": "Jan Kowalski" }
  ],
  "total_blocks": 142,
  "credits_used": 3
}

Example

python
import base64
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_...")

with open("form.pdf", "rb") as f:
    doc_b64 = base64.b64encode(f.read()).decode()

result = client.document.analyze(
    document=doc_b64,
    features=["TABLES", "FORMS"]
)

# Access extracted tables
for table in result.tables:
    for row in table:
        print(" | ".join(row))

# Access form fields
for kv in result.key_values:
    print(f"{kv['key']}: {kv['value']}")
bash
curl -X POST "https://apis.fotohub.app/v1/ai/document/analyze" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "document": "BASE64_ENCODED_PDF...",
    "features": ["TABLES", "FORMS"]
  }'

Analyze Expense

Specialized extraction for invoices, receipts, and expense documents. Returns vendor info, line items, totals, tax, and dates in a structured format.

Endpoint

POST /v1/ai/document/analyze-expense

Billing: 5 credits per document

Parameters

ParameterTypeRequiredDescription
documentstringYesBase64-encoded invoice/receipt. Max 10MB.

Response

json
{
  "expenses": [
    {
      "summary": {
        "VENDOR_NAME": { "value": "FOTOhub sp. z o.o.", "confidence": 98.7 },
        "INVOICE_RECEIPT_DATE": { "value": "2026-07-19", "confidence": 99.1 },
        "TOTAL": { "value": "61.49 PLN", "confidence": 99.5 },
        "TAX": { "value": "11.50 PLN", "confidence": 98.2 },
        "SUBTOTAL": { "value": "49.99 PLN", "confidence": 99.0 }
      },
      "line_items": [
        { "ITEM": "AI Credits Bundle (1000)", "QUANTITY": "1", "PRICE": "49.99 PLN" }
      ]
    }
  ],
  "document_count": 1,
  "credits_used": 5
}

Example

python
import base64
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_...")

with open("invoice.jpg", "rb") as f:
    doc_b64 = base64.b64encode(f.read()).decode()

result = client.document.analyze_expense(document=doc_b64)
for exp in result.expenses:
    print(f"Vendor: {exp['summary']['VENDOR_NAME']['value']}")
    print(f"Total: {exp['summary']['TOTAL']['value']}")
    for item in exp['line_items']:
        print(f"  - {item.get('ITEM', '?')}: {item.get('PRICE', '?')}")
bash
curl -X POST "https://apis.fotohub.app/v1/ai/document/analyze-expense" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "document": "BASE64_ENCODED_INVOICE..."
  }'

Pricing

OperationCreditsProvider CostUse Case
Detect Text (OCR)1$0.0015/pageSimple text extraction
Analyze (Tables+Forms)3$0.015/pageStructured document analysis
Analyze Expense5$0.01/pageInvoice/receipt processing

Error Responses

StatusCodeDescription
400unsupported_formatDocument format not supported. Use PDF, JPEG, PNG, or TIFF.
400document_too_largeFile exceeds 10MB limit.
402insufficient_creditsNot enough credits for this operation.
500analysis_failedInternal processing error. Retry or contact support.