API Documentation

The Image To Text API allows you to convert images containing text into machine-readable text. This documentation provides details on how to make requests to the API and the expected responses.

Base URL

The base URL for making API requests is:

https://www.imagetotext.info/api/imageToText

Authentication

To access the Image To Text API, you need to include an API key in the request header.

Header:

Authorization: Bearer YOUR_API_KEY

Replace 'YOUR_API_KEY' with your actual API key obtained from the service provider.

API Endpoints

1. Image File Upload

This endpoint allows you to directly upload an image file for text extraction.

Send a POST request to the base URL with the following headers and form data:

Header: Content-Type: multipart/form-data Form Data: image: (file) The image file to be converted.

2. Image URL

This endpoint allows you to provide the URL of the image to be processed for text extraction.

Send a POST request to the base URL with the following headers and JSON body:

Header: Content-Type: application/json JSON Body: image_url: (string) The URL of the image to be converted.

3. Base64 Image Data

This endpoint allows you to provide the image data as a Base64-encoded string.

Send a POST request to the base URL with the following headers and JSON body:

Header: Content-Type: application/json JSON Body: base64: (string) The base64-encoded image data (including the data URI prefix).

Curl Request Example

Place YOUR_API_KEY with your original API Key

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.imagetotext.info/api/imageToText',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('base64' => 'base64 encoded string'),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR_API_KEY',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
                    

Response Format

The API response will be in JSON format. The structure of the response depends on the success or failure of the request.

Success Response

{ "error": true, "result": "imagetotext.info" }
  • error: Indicates whether an error occurred (false for success).
  • result: The converted text or response message.

Error Response

{ "error": true, "message": "Authorization or Validation error" }
  • error: Indicates whether an error occurred (true for error).
  • message: A descriptive error message explaining the cause of the error.
x blocker

Adblock Detected

We're not asking for a billion-dollar investment. 😜 Just disable your ad blocker to help us keep our content free.