Mindee HTTP

Mindee-specific HTTP operations.

class BaseEndpoint(settings)

Base endpoint class for the Mindee API.

Parameters:

settings (MindeeApi) –

class CustomEndpoint(url_name, owner, version, settings)

Endpoint for all custom documents.

Parameters:
  • url_name (str) –

  • owner (str) –

  • version (str) –

  • settings (MindeeApi) –

annotations_req_del(document_id)

Make a request to DELETE annotations for a document.

Parameters:

document_id (str) – ID of the document to annotate

Return type:

Response

Returns:

requests response

annotations_req_post(document_id, annotations)

Make a request to POST annotations for a document.

Parameters:
  • document_id (str) – ID of the document to annotate

  • annotations (dict) – Annotations object

Return type:

Response

Returns:

requests response

annotations_req_put(document_id, annotations)

Make a request to PUT annotations for a document.

Parameters:
  • document_id (str) – ID of the document to annotate

  • annotations (dict) – Annotations object

Return type:

Response

Returns:

requests response

document_req_del(document_id)

Make a request to DELETE a document.

Parameters:

document_id (str) – ID of the document

Return type:

Response

document_req_get(document_id)

Make a request to GET annotations for a document.

Parameters:

document_id (str) – ID of the document

Return type:

Response

documents_req_get(page_id=1)

Make a request to GET info on all documents.

Parameters:

page_id (int, default: 1) – Page number

Return type:

Response

training_async_req_post(input_source, close_file=True)

Make a request to POST a document for training without processing.

Parameters:
  • input_source (LocalInputSource) – Input object

  • close_file (bool, default: True) – Whether to close() the file after parsing it.

Return type:

Response

Returns:

requests response

training_req_post(input_source, close_file=True)

Make a request to POST a document for training.

Parameters:
  • input_source (LocalInputSource) – Input object

  • close_file (bool, default: True) – Whether to close() the file after parsing it.

Return type:

Response

Returns:

requests response

class Endpoint(url_name, owner, version, settings)

Generic API endpoint for a product.

Parameters:
  • url_name (str) –

  • owner (str) –

  • version (str) –

  • settings (MindeeApi) –

document_feedback_req_put(document_id, feedback)

Send a feedback.

Parameters:
  • document_id (str) – ID of the document to send feedback to.

  • feedback (Dict[str, Any]) – Feedback object to send.

Return type:

Response

document_queue_req_get(queue_id)

Sends a request matching a given queue_id. Returns either a Job or a Document.

Parameters:

queue_id (str) – queue_id received from the API

Return type:

Response

openapi_get_req()

Get the OpenAPI specification of the product.

Return type:

Response

predict_async_req_post(input_source, include_words=False, close_file=True, cropper=False, full_text=False)

Make an asynchronous request to POST a document for prediction.

Parameters:
  • input_source (Union[LocalInputSource, UrlInputSource]) – Input object

  • include_words (bool, default: False) – Include raw OCR words in the response

  • close_file (bool, default: True) – Whether to close() the file after parsing it.

  • cropper (bool, default: False) – Including Mindee cropping results.

  • full_text (bool, default: False) – Whether to include the full OCR text response in compatible APIs.

Return type:

Response

Returns:

requests response

predict_req_post(input_source, include_words=False, close_file=True, cropper=False, full_text=False)

Make a request to POST a document for prediction.

Parameters:
  • input_source (Union[LocalInputSource, UrlInputSource]) – Input object

  • include_words (bool, default: False) – Include raw OCR words in the response

  • close_file (bool, default: True) – Whether to close() the file after parsing it.

  • cropper (bool, default: False) – Including Mindee cropping results.

  • full_text (bool, default: False) – Whether to include the full OCR text response in compatible APIs.

Return type:

Response

Returns:

requests response

class MindeeApi(api_key, endpoint_name, account_name, version)

Settings class relating to API requests.

Parameters:
  • api_key (Optional[str]) –

  • endpoint_name (str) –

  • account_name (str) –

  • version (str) –

set_base_url(value)

Set the base URL for all requests.

Return type:

None

Parameters:

value (str) –

set_from_env()

Set various parameters from environment variables, if present.

Return type:

None

set_timeout(value)

Set the timeout for all requests.

Return type:

None

Parameters:

value (Union[str, int]) –

api_key: Optional[str]

API Key for the client.

property base_headers: Dict[str, str]

Base headers to send with all API requests.

base_url: str
request_timeout: int
clean_request_json(response)

Checks and correct the response error format depending on the two possible kind of returns.

Parameters:

response (Response) – Raw request response.

Return type:

Dict[str, Any]

Returns:

Returns the job error if the error is due to parsing, returns the http error otherwise.

is_valid_async_response(response)

Checks if the asynchronous response is valid. Also checks if it is a valid synchronous response.

Returns True if the response is valid.

Parameters:

response (Response) – a requests response object.

Return type:

bool

Returns:

bool

is_valid_sync_response(response)

Checks if the synchronous response is valid. Returns True if the response is valid.

Parameters:

response (Response) – a requests response object.

Return type:

bool

Returns:

bool