Image to Text API

The Image to Text API detects and extracts text from images using state-of-the-art optical character recognition (OCR) algorithms. It can detect texts of different sizes, fonts, and even handwriting.

/v1/imagetotext

HTTP POST

Given an input image, return all detected texts and their bounding boxes.

Files

image (required) - image file to extract text from. Must be either JPEG or PNG format.

Headers

X-Api-Key (required) - API Key associated with your account.

Sample Request URL

Live Demo!

https://api.api-ninjas.com/v1/imagetotext

Sample Response


Code Examples


import requests

api_url = 'https://api.api-ninjas.com/v1/imagetotext'
image_file_descriptor = open('YOUR_IMAGE.jpeg', 'rb')
files = {'image': image_file_descriptor}
r = requests.post(api_url, files=files)
print(r.json())
var formData = new FormData();
formData.append('image', $('#YOUR_IMAGE_FILE')[0].files[0]);
$.ajax({
    method: 'POST',
    url: 'https://api.api-ninjas.com/v1/imagetotext',
    data: formData,
    enctype: 'multipart/form-data',
    processData: false,
    contentType: false, 
    success: function(result) {
        console.log(result);
    },
    error: function ajaxError(jqXHR, textStatus, errorThrown) {
        alert(jqXHR.responseText);
    }
});
If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.