OCR Image API Documentation

This API lets you upload an image and returns extracted text using OCR.

Endpoint

POST /ocr

Full Example: https://ocr.demohub.in.net/ocr

Headers (required)

Header Type Description Example Value
X-API-KEY string API authentication key XXXXXXXXX
code string Security code XXXXXXXXX
Origin / Referer string Originating domain (for CORS) XXXXXXXXX

Request (POST Form Data)

Field Type Required? Description
image file Yes The image file to extract text from

Content-Type: multipart/form-data

Example Request: curl

curl -X POST https://ocr.demohub.in.net/ocr \
  -H "X-API-KEY: XXXXXXXXX" \
  -H "code: XXXXXXXXX" \
  -F "image=@/path/to/image.jpg"
        

Success Response 200 OK

{
  "success": true,
  "message": "OCR successful.",
  "text": "Extracted text here"
}
      

Error Response Examples

401 Unauthorized:
{"success": false, "message": "Invalid API key.", "text": ""}
403 Forbidden (domain):
{"success": false, "message": "Access denied from this domain.", "text": ""}
400 Bad Request (no image):
{"success": false, "message": "No image uploaded.", "text": ""}
200 OK but OCR failed:
{"success": false, "message": "OCR failed: ...", "text": ""}

Notes & Tips

Sample JavaScript (Fetch)

const formData = new FormData();
formData.append('image', fileInput.files[0]);
fetch('http://localhost:5000/ocr', {
  method: 'POST',
  headers: {
    'X-API-KEY': 'a',
    'code': 'a'
  },
  body: formData
})
  .then(res => res.json())
  .then(data => console.log(data));