Recognize a Photo of a Receipt & Extract Key Business Information with JavaScript

Cloudmersive
1 min readMay 18, 2022

If you’re building an app for expensing receipts, we have an API that can help. Our Receipt Recognition OCR API is designed to pull key information from a photograph of a receipt including timestamps, business names, business websites, address, phone numbers, and more. It’s simple to use — just follow instructions below to structure your API call in JavaScript, and register for a free account on our website to get a Cloudmersive API key.

Let’s begin with installing the jQuery library for this API. Run the following command:

bower install jquery

Next, let’s include the code for the API call. As you can see, there are several parameters to satisfy, including adding the image file itself, the option to engage handwriting recognition (by specifying ‘EnableHandwriting’), and the option to specify language:

var form = new FormData();
form.append("imageFile", fileInput.files[0], "file");
var settings = {
"url": "https://api.cloudmersive.com/ocr/photo/recognize/receipt",
"method": "POST",
"timeout": 0,
"headers": {
"recognitionMode": "<string>",
"language": "<string>",
"preprocessing": "<string>",
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});

After that, you’re good to go. Give it a whirl!

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.