Search by

dessop / ocr

dessop.mx

DESSOP OCR API PHP SDK

Package info

github.com/Dessop/ocr

pkg:composer/dessop/ocr

Statistics

Installs: 14

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-09-15 21:50 UTC

This package is auto-updated.

Last update: 2026-09-16 23:23:31 UTC


README

Official PHP SDK for the DESSOP OCR API.

Package: dessop/ocr
API: https://ocr.dessop.com

Requirements

  • PHP 8.2+
  • Composer 2+

Installation

composer require dessop/ocr

Configuration

use Dessop\Ocr\OcrClient;

$ocr = new OcrClient(
    'https://ocr.dessop.com',
    getenv('DESSOP_OCR_API_KEY'),
    300,
);

Process a document

$result = $ocr->process('/path/to/document.pdf');

if ($result->successful()) {
    echo $result->text();
}

The synchronous request uses POST /ocr.

Process asynchronously

$job = $ocr->processAsync('/path/to/document.pdf');

echo $job->jobId();
echo $job->status(); // pending, processing, completed or failed

submit() is an alias for processAsync().

Query a job and retry a failed job:

$job = $ocr->getJob($jobId);

if ($job->status() === 'completed') {
    echo $job->text();
}

$ocr->retryJob($jobId);

job() is an alias for getJob().

Available methods:

$result->jobId();
$result->filename();
$result->pages();
$result->text();
$result->client();
$result->data();
$result->get('some.nested.value');
$result->status();
$result->documentId();

Documents and files

$documents = $ocr->documents();
$document = $ocr->document($documentId);
$text = $ocr->documentText($documentId);
$originalFile = $ocr->documentFile($documentId);
$ocrPdf = $ocr->documentOcrPdf($documentId);

The file methods return the downloaded binary content from DESSOP OCR.

Health check

if ($ocr->health()) {
    echo 'DESSOP OCR is available.';
}

This calls GET /health.

Exceptions

  • OcrAuthenticationException
  • OcrValidationException
  • OcrTimeoutException
  • OcrServerException
  • OcrException

HTTP 401 and 403 responses throw OcrAuthenticationException; validation errors (422), timeouts (408/504 or connection timeout), rate limits (429), server errors (500+) and invalid JSON are mapped to the SDK exceptions above.

Security

Never hardcode the API key. Store it in an environment variable or secret manager. Never log the key or send it to frontend code.

License

MIT. Copyright (c) 2026 DESSOP.