Home API Tools Posts Hire Me About
Sign In Create Account
Live Free tier included

Document OCR & Data Extraction

Extract text from images and scanned documents using Tesseract OCR. Auto-detects emails, phone numbers, dates, and monetary amounts with structured output.

Tesseract OCR Auto-extract Data Multi-language Receipts & Invoices

Try it Free

Upload an image and extract text with structured data in seconds.

Try Free
Uploading image...
Result

Upload an image to extract text

API Documentation

Extract text from images and scanned documents using Tesseract OCR. Auto-detects emails, phone numbers, dates, and monetary amounts. Supports 20+ languages including Arabic.

Endpoint

POSThttps://www.mahmoudalhabash.com/api/v1/ocr

Upload an image file or send base64-encoded image data. The API runs Tesseract OCR and returns extracted text with word-level confidence scores and structured data extraction.

Request Parameters

ParameterTypeRequiredDefaultDescription
imagefilerequired*Image file (JPG, PNG, GIF, WebP, BMP, TIFF, max 10MB)
base64stringrequired*Base64-encoded image (alternative to file upload)
languagestringoptionalengTesseract language code (eng, ara, fra, deu, spa, etc.)
typestringoptionalautoDocument type: auto, receipt, invoice, id_card, general

* Either image file or base64 is required.

Response Fields

text Full extracted text
word_count Number of words extracted
confidence Average OCR confidence (0–100)
structured.emails Auto-detected email addresses
structured.phones Auto-detected phone numbers
structured.dates Auto-detected dates
structured.amounts Auto-detected monetary amounts
structured.total Detected total amount (receipts/invoices)
blocks Word-level bounding boxes with confidence scores

Code Examples

cURL (file upload)
curl -X POST https://www.mahmoudalhabash.com/api/v1/ocr \ -F "image=@receipt.jpg" \ -F "language=eng" \ -F "type=receipt"
Response 200JSON
{ "status": "success", "text": "Coffee Shop\nDate: 03/11/2026\n...", "word_count": 45, "confidence": 94.2, "structured": { "emails": [], "phones": ["+1-555-0123"], "dates": ["03/11/2026"], "amounts": ["$4.50", "$12.99"], "total": "12.99" }, "took_ms": 1200 }
Python (requests)
import requests with open('document.png', 'rb') as f: resp = requests.post( 'https://www.mahmoudalhabash.com/api/v1/ocr', files={'image': f}, data={ 'language': 'eng', 'type': 'auto' } ) data = resp.json() print(f"Text: {data['text'][:200]}") print(f"Confidence: {data['confidence']}%") print(f"Emails: {data['structured']['emails']}") print(f"Amounts: {data['structured']['amounts']}")

Error Codes

422 Validation failed — image or base64 required, max 10MB
422 No text extracted — try a clearer image or different language
429 Rate limit exceeded
500 Tesseract OCR processing failed

Rate Limits

Unlimited — Free during beta

Powered by Tesseract OCR v5. Max file size 10MB. Supports file upload or base64 input. No data is stored — images are processed and immediately discarded.