Skip to content

OCR API

OCR APIs cover OCR file export, single-image text block extraction, and static image barcode/QR recognition. In the current CZUR implementation, the OCR provider is czur-ocr-provider, and the static recognition provider is czur-recognition-provider.

OCR and Recognition Methods

MethodParametersResponse dataNotes
ocr.recognizeinput_upload_id?: string, input_upload_ids?: string[], input_path?: string, input_files?: string[], output_path?: string, output_dir?: string, format?: txt|pdf|docx|xlsx|ofd|json=docx, exportType?: multi-page|single-page=multi-page, export_type?: multi-page|single-page, params?: object, ext_params?: objecttask_id, task, input_count, output_path, output_dir, output_paths[], format, exportType, providerSubmits an asynchronous OCR export task.
ocr.gettask_id: string requiredtask, providerGets an OCR task snapshot.
ocr.canceltask_id: string requiredcancelled, task, providerRequests cancellation for an OCR task.
ocr.extract_textinput_upload_id?: string or input_path?: stringrecognized, input_path, width, height, blocks[], providerRuns lightweight OCR on one image and returns text blocks in image coordinates.
recognition.barcode_detectinput_upload_id?: string or input_path?: string, formats?: string[], compatible detect_type?: string[]detected, count, input_path, width, height, barcodes[], providerDetects barcode/QR content from one static image. Realtime barcode recognition belongs to capture/video streams.

ocr.recognize Input Rules

ItemNotes
Input imagesinput_upload_id and input_upload_ids are resolved to asset-original local files visible to the current connection. input_path and input_files use local paths directly. These inputs are merged, and at least one input file is required.
Export formatformat supports txt, pdf, docx, xlsx, ofd, and json. When omitted, it is inferred from the output_path extension first, then defaults to docx. jpg / jpeg are not OCR export formats and return an invalid-params error.
Multi-page exportWhen exportType / export_type is multi-page, multiple inputs are exported to one file and output_path is required. This is the default mode.
Single-page exportWhen exportType / export_type is single-page, each input is exported to one file and output_dir must be derivable. If only output_path is provided, a path without extension is treated as the directory; a path with extension uses its parent directory.
Export parametersparams and ext_params are merged and passed through to the OCR engine. Top-level encoding, paperSize, exportType, ocrPreference, quality, and exportFormat are also copied into the passthrough parameters. The normalized format and exportType are written last.
Task stateocr.recognize returns the queued task snapshot. Query progress with ocr.get. The current OCR module does not push task events.

export_type also accepts underscore aliases: single_page is normalized to single-page, and multi_page is normalized to multi-page.

ocr.task Fields

FieldTypeNotes
task_idstringOCR task ID, such as ocr-1.
statusstringqueued, processing, completed, failed, cancelled, or unknown.
progressnumberTask progress, from 0 to 100.
output_pathstringTarget file for multi-page export; output directory for single-page export.
output_paths[]string[]Planned or completed output paths. Multi-page export usually has one path; single-page export contains one path per input.
formatstringNormalized export format.
exportTypestringNormalized export mode: multi-page or single-page.
messagestringCurrent stage or result message.
errorstringFailure reason; empty when there is no error.

ocr.extract_text Output

ocr.extract_text processes one image. The input can be input_upload_id or input_path. Response width, height, and blocks[] use the original image coordinate system.

FieldTypeNotes
recognizedbooleanWhether OCR completed successfully.
input_pathstringLocal image path actually processed.
width / heightnumberInput image dimensions.
blocks[]arrayRecognized text blocks.
providerstringCurrently czur-ocr-provider.

blocks[] fields:

FieldTypeNotes
textstringRecognized text.
x / ynumberTop-left coordinate of the text block.
width / heightnumberText block rectangle size.
confidencenumberOCR confidence score.
font_sizenumberEstimated font size; if the engine does not return a font size, it is estimated from block height.

recognition.barcode_detect Output

recognition.barcode_detect processes one static image. When formats is empty, the default formats are qrcode, pdf417, code128, ean13, ean8, upca, upce, code39, and codabar.

FieldTypeNotes
detectedbooleanWhether barcode/QR content was detected.
countnumberNumber of barcodes[]. The current implementation returns one best result.
input_pathstringLocal image path actually processed.
width / heightnumberInput image dimensions.
barcodes[]arrayBarcode/QR results.
providerstringCurrently czur-recognition-provider.

Supported formats[] values include: qrcode / qr_code, pdf417 / pdf_417, code128 / code_128, code39 / code_39, ean13 / ean_13, ean8 / ean_8, upca / upc_a, upce / upc_e, codabar, datamatrix / data_matrix, aztec, maxicode, itf, rss14 / rss_14, rss_expanded, and upc_ean_extension.

barcodes[] fields:

FieldTypeNotes
formatnumberZXing internal format enum value.
format_namestringZXing format name.
textstringBarcode/QR content.
points[]arrayDetection points with x and y.

Request Examples

Export OCR into one multi-page file:

json
{
  "request_id": "req-ocr-001",
  "method": "ocr.recognize",
  "params": {
    "input_upload_ids": ["img-1760000000-1", "img-1760000000-2"],
    "output_path": "/tmp/demo.txt",
    "format": "txt",
    "exportType": "multi-page",
    "encoding": "utf-8",
    "quality": 90
  }
}

Export OCR into one file per input image:

json
{
  "request_id": "req-ocr-single-001",
  "method": "ocr.recognize",
  "params": {
    "input_files": ["/tmp/page-1.jpg", "/tmp/page-2.jpg"],
    "output_dir": "/tmp/ocr-pages",
    "format": "docx",
    "exportType": "single-page"
  }
}

Extract text blocks from one image:

json
{
  "request_id": "req-ocr-text-001",
  "method": "ocr.extract_text",
  "params": {
    "input_upload_id": "img-1760000000-1"
  }
}

Detect barcode/QR content from a static image:

json
{
  "request_id": "req-barcode-001",
  "method": "recognition.barcode_detect",
  "params": {
    "input_upload_id": "img-1760000000-1",
    "formats": ["qrcode", "pdf417", "code128"]
  }
}

CZUR Open Platform Documentation