How do I query an OCR model

Once you have trained a Nanonets OCR model or are using one of our Pretrained models (instructions to train your own OCR model can be found here https://nanonets.com/help/how-to-build-an-ocr-model-with-nanonets)  you can query the API using the following instructions:


1. Find your model from My Models page:

Go to https://app.nanonets.com/#/models and select the model of your choice and click Go To Model


2. Go to the integrate page for your model

Got to the Integrate tab (found in the left hand sidebar). There you can go and select the language of your choice (Java, C#, Python, Nodejs, Javascript, Ruby etc). You can find the link to your model page by visiting 


Here are the details for web request being sent (as a cURL command)

curl \
--request POST \
--url 'https://app.nanonets.com/api/v2/OCR/Model/replace-with-your-model-id-goes-here/LabelUrls/' \
--header 'accept: application/x-www-form-urlencoded' \
-d 'urls=https://replace.with.your/image/url.jpg' \
-u 'replace-with-your-api-key:'


2. Copy the code and run. The api response will look like:

{
    "message": "Success",
    "result": [
        {
            "message": "Success",
            "input": "https://url.to.file/223179695.jpeg",
            "prediction": [
                {
                    "label": "buyer_name",
                    "xmin": 298,
                    "ymin": 712,
                    "xmax": 561,
                    "ymax": 755,
                    "score": 1,
                    "ocr_text": "Unit4 N.V."
                },
                {
                    "label": "buyer_address",
                    "xmin": 298,
                    "ymin": 850,
                    "xmax": 805,
                    "ymax": 961,
                    "score": 1,
                    "ocr_text": "Stationspark 1000\n3364 DA Sliedrecht"
                },
                {
                    "label": "invoice_date",
                    "xmin": 744,
                    "ymin": 1200,
                    "xmax": 1091,
                    "ymax": 1241,
                    "score": 1,
                    "ocr_text": "2 March 2019"
                },
                {
                    "label": "invoice_amount",
                    "xmin": 1820,
                    "ymin": 2241,
                    "xmax": 2074,
                    "ymax": 2291,
                    "score": 1,
                    "ocr_text": "€ 19.360.00"
                }
            ],
            "page": 0,
            "request_file_id": "629bb44b-39be-4b59-b504-18bfa7621bba",
            "filepath": "1382024497.jpeg"
        }
    ]
}

Was this article helpful?