api

Image to Text API

AI Image to text converter API For public use, Now you can integrate ImgOCR API in your applications, hobby and educational projects

Now officially imgOCR has launched its API for member users, they can log in And get their API key with a FREE 100 tokens Gift 🎁

Image to text API Documentation

It is straightforward to use ImgOCR API using API auth. You need to send the Payload image as BASE64 and the API key. It will return results as JSON with a text object or error object value.

"API KEY IS A HIGHLY CONFIDENTIAL STRING, KEEP IT SECURE TO SAVE YOUR TOKENS FROM BEING WASTED"

Sample PHP cURL Code:

 


<?php
set_time_limit( -1 );
function sendPostRequest($url, $filePath) {
    // Initialize cURL session
    $ch = curl_init();

    // Prepare the file for upload
    $fileData = base64_encode( file_get_contents( $filePath ) );
    // Prepare the POST fields
    $postData = [
        'api_key' => 'YOUR_API_KEY_HERE',
        'image' => $fileData
    ];

    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    // -- IMPORTANT If Your are behind Firewall
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    // Execute the request
    $response = curl_exec($ch);

    // Check for errors
    if (curl_errno($ch)) {
        return 'cURL error: ' . curl_error($ch);
    } else {
        return $response;
    }

    // Close cURL session
    curl_close($ch);
}

// Usage example
$url = 'https://www.imgocr.com/api/imgocr_get_text';
$filePath = 'my_sample_image.png';

// Run the function
echo sendPostRequest($url, $filePath);
?>

That's it for the requesting method you can fetch Image output. let me tell you about possible outputs

Image to Text Converter API Possible Output

This API will provide Possible outputs in JSON objects, It could be extracted text from an image as output or error during validation, or processing of the image.

Here you can see possible Output responses:

Success (HTTP 200) JSON "text" object of extract string from the image
Failed (HTTP 503) Error Object due to server busy mode, or a validation processing issue.
Failed (HTTP 401) Error not enough tokens to process image OCR
Failed (HTTP 401) Error due to invalid API Key, or unauthorized access.

Get your API key now and Enjoy ImgOCR with an API Key.