Synchronous Prediction

Send my document

URL

POST /predict

https://api.mindee.net/v1/products/mindee/<name>/<version>/predict

To make synchronous predictions, make sure your document parsing API supports synchronous mode, then select:

  • <name> refers to the name and selected version of your Off-the-shelf APIs.

  • <version> refers to the API version as described in your API Documentation. A new version may not be fully backward compatible and bring new features and better performance.

Prepare payload

The Prediction endpoint can handle three types of payload in order to send your document:

  • a binary file

  • a base64 encoded file

  • a URL

See Document inputs for more information on supported files.

Binary File

Use a multipart/form-data encoding to send your document:

curl -X POST 
  https://api.mindee.net/v1/products/mindee/<api_name>/<api_version>/predict 
  -H 'Authorization: Token <my-api-key-here>'
  -F document=@/path/to/your/file.png

Base64 Encoded File

Prepare a JSON payload:

{
  "document": "/9j......"
}

Send your request with an application/json encoding:

curl -X POST \
  https://api.mindee.net/v1/products/mindee/<api_name>/<api_version>/predict \
  -H 'Authorization: Token <my-api-key-here>' \
  -H 'Content-Type: application/json' \
  -d 'document="/9j..."'

Public URL

Prepare a JSON payload with the URL included. Only valid public HTTPS links are accepted:

{
  "document": "https://mydomain.com/my_file.pdf"
}

Send your request with an application/json encoding:

curl -X POST \
  https://api.mindee.net/v1/products/mindee/<api_name>/<api_version>/predict \
  -H 'Authorization: Token <my-api-key-here>' \
  -H 'Content-Type: application/json' \
  -d '{"document":"https://mydomain.com/my_file.pdf"}'

Get my prediction

See Endpoints for general description of Mindee's REST API response format.

JSON Response

When calling the prediction endpoint, the parsed information from your documents can be found in the document key.

{
  "api_request": { .. }, 
  "document": {
    "id": "ac668055-e7db-48f2-b81f-e5ba9a6a6b8f",
    "name": "myfile.pdf",
    "n_pages": 2,
    "inference": {
      "started_at": "2021-03-24T09:14:27",
      "finished_at": "2021-03-24T09:14:28",
      "processing_time": 1.087,
      "is_rotation_applied": true,
      "extras": {},
      "prediction": { .. },
      "pages": [
        {
          "id": 0,
          "orientation": {"value": 0},
          "extras": {},
          "prediction": { .. }
        },
        {
          "id": 1,
          "orientation": {"value": 0},
          "extras": {},
          "prediction": { .. }
        }
      ]
    }
  }
}

Document

Describes the uploaded document

key
type
description

id

string

a unique identifier

name

string

the filename

n_pages

number

the number of pages

inference

object

a JSON object with the content of your inference (prediction)

Document > Inference

Contains the whole inference data (predictions)

[block:parameters] { "data": { "h-0": "key", "h-1": "type", "h-2": "description", "0-0": "started_at", "0-1": "string", "0-2": "the date & time the inference has started in ISO 8601 format", "1-0": "finished_at", "1-1": "string", "1-2": "the date & time the inference was finished in ISO 8601 format", "2-0": "processing_time", "2-1": "number", "2-2": "the request processing time in seconds", "3-0": "is_rotation_applied", "3-1": "boolean or null", "3-2": "true: polygons are already rotated given the page orientation \nfalse: polygons are never rotated \nnull: the API has no orientation information", "4-0": "extras", "4-1": "object", "4-2": "a JSON object with document-level extras predictions", "5-0": "prediction", "5-1": "object", "5-2": "a JSON object with the document-level API prediction", "6-0": "pages", "6-1": "list[object]", "6-2": "a JSON object with the page-level inference data" }, "cols": 3, "rows": 7, "align": [ "left", "left", "left" ] } [/block]

Document > Inference > Pages[ ]

Contains the page-level specific inference data (predictions)

[block:parameters] { "data": { "h-0": "key", "h-1": "type", "h-2": "description", "0-0": "id", "0-1": "number", "0-2": "the page index", "1-0": "orientation.value", "1-1": "number", "1-2": "the clockwise rotation to apply to get the page upright \nExamples: 0, 90, 180, 270 ", "2-0": "extras", "2-1": "object", "2-2": "a JSON object with page-level extras predictions \n_Example: the Cropper feature_", "3-0": "prediction", "3-1": "object", "3-2": "a JSON object with the page-level API prediction" }, "cols": 3, "rows": 4, "align": [ "left", "left", "left" ] } [/block]

Prediction example

Each API can describe several fields within its prediction object. Depending on the field properties, you will find values, a confidence score or polygons.

{
  "prediction": {
    "locale": {
      "country": "CA",
      "currency": "CAD",
      "language": "en",
      "value": "en-CA",
      "confidence": 0.85
    },
    "date": {
      "value": "2020-07-03",
      "confidence": 0.99,
      "polygon": [[0.273, 0.355], [0.289, 0.355], [0.289, 0.373], [0.273, 0.373]]
    },
    "total_incl": {
      "value": 14.32,
      "confidence": 0.98,
      "polygon": [[0.581, 0.485], [0.696, 0.485], [0.696, 0.503], [0.581, 0.503]]
    }
  }
}

Last updated

Was this helpful?