OCR API

The OCR (Optical Character Recognition) API extracts text from images and documents with high accuracy and supports structured data extraction for specific document types.

Base URL

https://api.zaits.net/v1/ocr

Authentication

All requests require your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Text Extraction

Extract text from any document or image.

Endpoint

POST /v1/ocr/extract

Parameters

Parameter
Type
Required
Description

image

file

Document image (JPG, PNG, PDF)

language

string

Language code (e.g., "en", "es", "auto")

output_format

string

Output format: text, json, structured

Supported Languages

  • auto - Auto-detect (default)

  • en - English

  • es - Spanish

  • fr - French

  • de - German

  • it - Italian

  • pt - Portuguese

  • And 100+ more languages

Request Example

curl -X POST https://api.zaits.net/v1/ocr/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "[email protected]" \
  -F "language=en" \
  -F "output_format=structured"

Response

{
  "success": true,
  "data": {
    "text": "Complete extracted text content from the document...",
    "confidence": 0.95,
    "language_detected": "en",
    "page_count": 1,
    "processing_time": 2.1,
    "regions": [
      {
        "text": "Header Text",
        "confidence": 0.98,
        "bounding_box": {
          "x": 10,
          "y": 20,
          "w": 200,
          "h": 30
        }
      },
      {
        "text": "Body paragraph content...",
        "confidence": 0.94,
        "bounding_box": {
          "x": 10,
          "y": 60,
          "w": 400,
          "h": 120
        }
      }
    ],
    "metadata": {
      "image_dimensions": {
        "width": 1200,
        "height": 800
      },
      "dpi": 300
    }
  }
}

Document-Specific OCR

Extract structured data from specific document types with intelligent field recognition.

Endpoint

POST /v1/ocr/extract/document

Parameters

Parameter
Type
Required
Description

image

file

Document image

document_type

string

Document type (see supported types below)

extract_tables

boolean

Extract table data (default: false)

Supported Document Types

  • invoice - Business invoices

  • receipt - Purchase receipts

  • contract - Legal contracts

  • form - Government forms

  • bank_statement - Bank statements

  • tax_document - Tax forms

  • medical_report - Medical documents

  • insurance_claim - Insurance forms

Request Example

curl -X POST https://api.zaits.net/v1/ocr/extract/document \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "[email protected]" \
  -F "document_type=invoice" \
  -F "extract_tables=true"

Response (Invoice Example)

{
  "success": true,
  "data": {
    "document_type": "invoice",
    "confidence": 0.92,
    "fields": {
      "invoice_number": "INV-2025-001",
      "date": "2024-01-15",
      "due_date": "2024-02-14",
      "total_amount": 1234.56,
      "currency": "USD",
      "tax_amount": 123.45,
      "subtotal": 1111.11,
      "vendor": {
        "name": "Acme Corporation",
        "address": "123 Business St, City, State 12345",
        "tax_id": "123456789"
      },
      "customer": {
        "name": "John Doe",
        "address": "456 Customer Ave, City, State 67890"
      },
      "line_items": [
        {
          "description": "Product A",
          "quantity": 2,
          "unit_price": 500.00,
          "total": 1000.00
        },
        {
          "description": "Service B",
          "quantity": 1,
          "unit_price": 111.11,
          "total": 111.11
        }
      ]
    },
    "tables": [
      {
        "rows": 3,
        "columns": 4,
        "data": [
          ["Item", "Qty", "Price", "Total"],
          ["Product A", "2", "$500.00", "$1000.00"],
          ["Service B", "1", "$111.11", "$111.11"]
        ]
      }
    ],
    "raw_text": "Full extracted text content...",
    "processing_time": 3.2
  }
}

Receipt OCR

Specialized OCR for retail receipts with merchant and item recognition.

Endpoint

POST /v1/ocr/extract/receipt

Parameters

Parameter
Type
Required
Description

image

file

Receipt image

currency

string

Expected currency (e.g., "USD", "EUR")

extract_items

boolean

Extract individual items (default: true)

Request Example

curl -X POST https://api.zaits.net/v1/ocr/extract/receipt \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "[email protected]" \
  -F "currency=USD" \
  -F "extract_items=true"

Response

{
  "success": true,
  "data": {
    "merchant": {
      "name": "SuperMart",
      "address": "789 Shopping Blvd, City, State",
      "phone": "(555) 123-4567"
    },
    "transaction": {
      "date": "2024-01-15",
      "time": "14:32:00",
      "transaction_id": "TXN123456"
    },
    "totals": {
      "subtotal": 42.00,
      "tax": 3.67,
      "total": 45.67,
      "currency": "USD"
    },
    "payment": {
      "method": "Credit Card",
      "card_last_four": "1234",
      "amount_paid": 45.67,
      "change": 0.00
    },
    "items": [
      {
        "description": "Apples - Organic",
        "quantity": 2,
        "unit_price": 3.99,
        "total": 7.98
      },
      {
        "description": "Bread - Whole Wheat",
        "quantity": 1,
        "unit_price": 4.50,
        "total": 4.50
      },
      {
        "description": "Milk - 2% Gallon",
        "quantity": 1,
        "unit_price": 4.29,
        "total": 4.29
      }
    ],
    "confidence": 0.91,
    "processing_time": 1.8
  }
}

ID Card OCR

Extract information from government-issued ID cards and driver's licenses.

Endpoint

POST /v1/ocr/extract/id

Parameters

Parameter
Type
Required
Description

image

file

ID card image

document_type

string

ID type: drivers_license, passport, national_id

country

string

Country code (e.g., "US", "CA", "MX")

Request Example

curl -X POST https://api.zaits.net/v1/ocr/extract/id \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "image=@drivers_license.jpg" \
  -F "document_type=drivers_license" \
  -F "country=US"

Response

{
  "success": true,
  "data": {
    "document_type": "drivers_license",
    "country": "US",
    "state": "CA",
    "personal_info": {
      "first_name": "John",
      "middle_name": "Michael",
      "last_name": "Doe",
      "full_name": "John Michael Doe",
      "date_of_birth": "1990-01-01",
      "gender": "M",
      "height": "6'0\"",
      "weight": "180 lbs",
      "eye_color": "BRN",
      "hair_color": "BLK"
    },
    "address": {
      "street": "123 Main Street",
      "city": "Los Angeles",
      "state": "CA",
      "zip_code": "90210"
    },
    "document_info": {
      "id_number": "D1234567",
      "issue_date": "2020-01-15",
      "expiry_date": "2028-01-15",
      "class": "C"
    },
    "confidence": 0.94,
    "processing_time": 2.3
  }
}

Document Authenticity Verification

Verify document authenticity using advanced security feature detection.

Endpoint

POST /v1/ocr/verify/authenticity

Parameters

Parameter
Type
Required
Description

image

file

Document image

document_type

string

Type of document to verify

country

string

Country of origin

Supported Document Types for Verification

  • passport - Passports

  • drivers_license - Driver's licenses

  • national_id - National ID cards

  • birth_certificate - Birth certificates

  • social_security_card - SSN cards

Request Example

curl -X POST https://api.zaits.net/v1/ocr/verify/authenticity \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "[email protected]" \
  -F "document_type=passport" \
  -F "country=US"

Response

{
  "success": true,
  "data": {
    "is_authentic": true,
    "confidence": 0.92,
    "risk_score": 0.08,
    "security_features": {
      "watermark_detected": true,
      "micro_printing": true,
      "holographic_elements": true,
      "uv_features": false,
      "rfid_chip": true,
      "barcode_validation": true
    },
    "authenticity_checks": [
      {
        "check": "Font Analysis",
        "status": "pass",
        "confidence": 0.95
      },
      {
        "check": "Layout Verification",
        "status": "pass", 
        "confidence": 0.89
      },
      {
        "check": "Security Pattern",
        "status": "pass",
        "confidence": 0.92
      }
    ],
    "anomalies": [],
    "processing_time": 4.1
  }
}

Error Responses

Common OCR Errors

Error Code
HTTP Status
Description

no_text_detected

400

No readable text found in the image

poor_image_quality

400

Image quality too low for OCR

unsupported_language

400

Specified language not supported

document_type_mismatch

400

Document doesn't match specified type

image_orientation_error

400

Image needs to be rotated

multi_page_not_supported

400

Multi-page documents not supported for this endpoint

Error Response Format

{
  "success": false,
  "error": {
    "code": "poor_image_quality",
    "message": "The image quality is too low for reliable OCR processing",
    "details": {
      "image_resolution": "150x200",
      "min_recommended": "300x400",
      "suggestions": [
        "Use higher resolution images (min 300 DPI)",
        "Ensure good lighting and contrast",
        "Avoid blurry or distorted images"
      ]
    }
  }
}

Best Practices

Image Requirements

  • Format: JPG, PNG, PDF (single page)

  • Size: Max 10MB per file

  • Resolution: Min 300 DPI recommended

  • Orientation: Upright, properly aligned

  • Lighting: Even, well-lit images

  • Focus: Sharp, clear text

Performance Tips

  • Crop to relevant area to improve accuracy

  • Use high contrast images (dark text on light background)

  • Rotate images to correct orientation before uploading

  • Compress large files while maintaining quality

  • Use appropriate document type for structured extraction

Language Detection Tips

  • Set language=auto for automatic detection

  • Specify language when known for better accuracy

  • Multi-language documents may have lower confidence

  • Some languages require specific fonts for optimal results


Next: Document Signing API

Last updated