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_get_text
99.9%
Uptime SLA
< 5s
Avg Response
50+
Languages
REST
Protocol
Base64
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 encoded as a Base64 string. Include your api_key in every request.

POST https://www.imgocr.com/api/imgocr_get_text
Request Parameters
POST body fields — application/x-www-form-urlencoded or multipart/form-data
Parameter Type Required Description
api_key string Required Your unique API key obtained from your account dashboard.
image string (base64) Required Base64-encoded content of the image file. Supports JPG, PNG, WEBP formats up to 30 MB.
Response Schema
JSON response format for all API calls
200 OK — Success
{
  "message": "success",
  "text": "Extracted text..."
}
4xx / 5xx — Error
{
  "message": "fail",
  "error": "Error description..."
}
Field Type Description
message string "success" on success, "fail" on error.
text string The extracted text from the image. Only present on success.
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();

    // Encode image as Base64
    $fileData = base64_encode(file_get_contents($filePath));

    // Build POST payload
    $postData = [
        'api_key' => 'API_KEY_STRING_HERE',
        'image'   => $fileData,
    ];

    // 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'];
    }

    curl_close($ch);
}

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

def send_ocr_request(url, file_path):
    # Read and encode image
    with open(file_path, 'rb') as f:
        file_data = base64.b64encode(f.read()).decode('utf-8')

    # Build payload
    payload = {
        'api_key': 'API_KEY_STRING_HERE',
        'image':   file_data,
    }

    # Send request
    response = requests.post(url, data=payload, verify=False)

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

# Usage
url       = 'https://www.imgocr.com/api/imgocr_get_text'
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) {
    // Encode image as Base64
    const fileData = fs.readFileSync(filePath, { encoding: 'base64' });

    // Build form data
    const params = new URLSearchParams();
    params.append('api_key', 'API_KEY_STRING_HERE');
    params.append('image', fileData);

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

// Usage
const url      = 'https://www.imgocr.com/api/imgocr_get_text';
const filePath = 'image.png';
sendOcrRequest(url, filePath);
# Encode image and POST to the OCR API
curl -X POST https://www.imgocr.com/api/imgocr_get_text \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "api_key=API_KEY_STRING_HERE" \
  --data-urlencode "image=$(base64 -w 0 image.png)"

# Example successful response:
{ "message": "success", "text": "Your extracted text..." }
🛠️

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.