To make it simple, REST API defines a set of functions to which the develo3 can perform requests and receive responses. The interaction is performed via the HTTP protocol. An advantage of such an approach is the wide usage of HTTP. That is why REST API can be used practically for any programming language.
Common characteristics of Newocr.com REST API resources are as follows:
Authentication in API is realized using keys. The API key is provided for every request and is passed as a query string parameter. Request your free personal API key by filling form at the bottom of this page.
You can upload JPEG, PNG, GIF, BMP and multipage TIFF, PDF, DJVU files.
To use multipart upload, make a POST request to the method's /v1/upload URI and add the query parameter key=api_key, for example:
POST /v1/upload?key=api_key HTTP/1.1
Host: api.newocr.com
Content-Type: multipart/form-data; boundary=---------------------------41184676334
Content-Length: 29278
-----------------------------41184676334
Content-Disposition: form-data; name="file"; filename="filename.jpg"
Content-Type: image/jpeg
(Binary data not shown)
-----------------------------41184676334--
If the request succeeds, the server returns the HTTP 200 OK status code along with any metadata:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data":
{
"file_id": "6fa11ac55c10ade5dd4d6126c34d1e08",
"pages": 257
}
}
curl -H "Expect:" -F file=@./path/to/file http://api.newocr.com/v1/upload?key=api_key
<?php
$file = realpath('filename.tif');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://api.newocr.com/v1/upload?key=api_key');
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@'.$file));
$result = curl_exec($ch);
echo $result;
curl_close ($ch);
?>
After uploading the file, you can recognize the page.
To use OCR, make a GET request to the method's /v1/ocr URI and add the query parameters, for example:
GET /v1/ocr?key=api_key&file_id=12345&page=1&lang=eng&psm=6 HTTP/1.1
Host: api.newocr.com
If the request succeeds, the server returns the HTTP 200 OK status code along with any metadata:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data":
{
"text": "Recognized text",
"progress": "100"
}
}
file_id
- file identifier obtained from /v1/uploadpage
- page number in the multi-page documents such as PDF, TIFF, DJVUlang
- language(s) used for OCR (allowed values are):
aframharaasmazeaze_cyrlbelbenbodbosbrebulcatcebceschi_simchi_sim_vertchi_trachi_tra_vertchrcymdandan_frakdeudeu_frakdzoellengenmepoequesteusfasfinfrafrkfrmgleglggrcgujhathebhinhrvhunikuindislitaita_oldjavjpnjpn_vertkankatkat_oldkazkhmkirkorkor_vertkurkur_aralaolatlavlitltzmalmarmkdmltmonmrimsamyanepnldnorocioripanpolporpusqueronrussansinslkslk_frakslvsndspaspa_oldsqisrpsrp_latnsunswaswesyrtamtatteltgktglthatirtonturuigukrurduzbuzb_cyrlvieyidyor
psm
- page segmentation mode. Allowed values are:rotate
- image rotation in degrees. Allowed values are: 0, 90, 180, 270curl "http://api.newocr.com/v1/ocr?key=api_key&file_id=123&page=1&lang=eng&psm=6"
<?php
$ch = curl_init('http://api.newocr.com/v1/ocr?key=api_key&file_id=123&page=1&lang=eng&psm=6');
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
?>
To get the status of your API key, make a GET request to the method's /v1/key/status URI and add the query parameters, for example:
GET /v1/key/status?key=api_key HTTP/1.1
Host: api.newocr.com
If the request succeeds, the server returns the HTTP 200 OK status code along with any metadata:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data":
{
"key_status": "paid",
"paid_up_to": "2014-11-18 00:00:00",
"ocrs_left": "96"
}
}
You can recognize 20 images (pages) for free.
If you want to recognize more, please purchase the paid version of the key.
Price is 0.5 cents per recognition. For example, for 1000 recognitions you will pay just $5.
You can pay by PayPal to admin@newocr.com and then email us your API key, and amount you paid
Please contact us about acquiring of paid key by filling the form below.
Request free API key by filling this form.