This API lets you upload an image and returns extracted text using OCR.
POST /ocr
Full Example: https://ocr.demohub.in.net/ocr
| 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 |
| Field | Type | Required? | Description |
|---|---|---|---|
| image | file | Yes | The image file to extract text from |
Content-Type:
multipart/form-data
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": true,
"message": "OCR successful.",
"text": "Extracted text here"
}
{"success": false, "message": "Invalid API key.", "text": ""}
{"success": false, "message": "Access denied from this domain.", "text": ""}
{"success": false, "message": "No image uploaded.", "text": ""}
{"success": false, "message": "OCR failed: ...", "text": ""}
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));