API Documentation Image to Text API Documentation

API documentation for different kind of application code base in order to serve OCR programmatically. AI Image to text converter API For public use, Now you can integrate ImgOCR API in your applications, hobby and educational projects

POST https://www.imgocr.com/api/imgocr_ai_ocr
99.9%
Uptime SLA
< 9s*
Avg Response
Multiple
Languages
REST
Protocol
File
Image Format
API Endpoint
Base URL for all API requests

All API requests must be sent over HTTPS using the POST method with your image sent as a multipart/form-data file upload (for the new endpoint). Include your api_key in every request.

POST https://www.imgocr.com/api/imgocr_ai_ocr
POST https://www.imgocr.com/api/imgocr_get_text (Deprecated)
Request Parameters
POST body fields — multipart/form-data
Parameter Type Required Description
api_key string Required Your unique API key obtained from your account dashboard.
image file Required The image file (multipart/form-data). Supports JPG, PNG, WEBP formats up to 10 MB.
mode string Optional The OCR mode to use. simple_ocr (1 token) or advance_ocr (10 tokens). Default is simple_ocr.
Response Schema
JSON response format for all API calls
200 OK — Success (simple_ocr)
{
  "success": true,
  "text": "Extracted text..."
}
200 OK — Success (advance_ocr)
{
  "success": true,
  "plain_text": "Your extracted text...",
  "document_type": "Invoice",
  "confidence": 0.95,
  "data": {},
  "tables": []
}
4xx / 5xx — Error
{
  "success": false,
  "error": "Error description..."
}
Field Type Description
success boolean true on success, false on error.
text string The extracted text from the image (only in simple_ocr mode).
document_type string The type of document identified (only in advance_ocr mode).
data object Logical key/value extracted data (only in advance_ocr mode).
tables array Array of tabular data objects (only in advance_ocr mode).
error string Human-readable error message. Only present on failure.
Code Examples
Ready-to-use snippets for popular languages
<?php

function sendOcrRequest($url, $filePath) {
    // Initialize cURL session
    $ch = curl_init();

    // Build POST payload (multipart/form-data)
    $postData = [
        'api_key' => 'API_KEY_STRING_HERE',
        'mode'    => 'simple_ocr',
        'image'   => new CURLFile($filePath)
    ];

    // Configure cURL
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    // Execute and handle response
    $response = curl_exec($ch);

    if (curl_errno($ch)) {
        echo 'cURL error: ' . curl_error($ch);
    } else {
        $result = json_decode($response, true);
        echo $result['text'] ?? $result['error'] ?? 'Unknown response';
    }

    curl_close($ch);
}

// Usage
$url      = 'https://www.imgocr.com/api/imgocr_ai_ocr';
$filePath = 'image.png';
sendOcrRequest($url, $filePath);
?>
import requests
import base64

def send_ocr_request(url, file_path):
    # Build payload
    payload = {
        'api_key': 'API_KEY_STRING_HERE',
        'mode':    'simple_ocr',
    }

    # Read image and send request
    with open(file_path, 'rb') as f:
        files = { 'image': f }
        response = requests.post(url, data=payload, files=files, verify=False)

    if response.status_code == 200:
        data = response.json()
        print(data.get('text', data.get('error', 'Unknown response')))
    else:
        print(f"HTTP Error: {response.status_code}")

// Usage
url       = 'https://www.imgocr.com/api/imgocr_ai_ocr'
file_path = 'image.png'
send_ocr_request(url, file_path)
// Node.js — using built-in fetch (Node 18+)
const fs = require('fs');

async function sendOcrRequest(url, filePath) {
    // Build form data
    const formData = new FormData();
    formData.append('api_key', 'API_KEY_STRING_HERE');
    formData.append('mode', 'simple_ocr');
    
    // Read file and append as Blob
    const fileData = fs.readFileSync(filePath);
    const blob = new Blob([fileData]);
    formData.append('image', blob, 'image.png');

    try {
        const response = await fetch(url, {
            method: 'POST',
            body: formData,
        });
        const data = await response.json();
        console.log(data.text ?? data.error ?? 'Unknown response');
    } catch (err) {
        console.error('Request failed:', err);
    }
}

// Usage
const url      = 'https://www.imgocr.com/api/imgocr_ai_ocr';
const filePath = 'image.png';
sendOcrRequest(url, filePath);
# Upload image and POST to the OCR API
curl -X POST https://www.imgocr.com/api/imgocr_ai_ocr \
  -F "api_key=API_KEY_STRING_HERE" \
  -F "mode=simple_ocr" \
  -F "image=@image.png"

# Example successful response:
{ "success": true, "text": "Your extracted text..." }

* ~7 - 9s avg response time for image size up to 1MB.

🛠️

Need Help?

If you encounter any issues while integrating the imgOCR API, our team is ready to assist you quickly. We love improving the developer experience.

Contact Support

Share Your Experience

×

Any suggestion, query, or found a bug to report, You can Annonymously Write us.