Mindee HTTP
Mindee-specific HTTP operations.
- class BaseEndpoint(settings)
Base endpoint class for the Mindee API.
- Parameters:
settings (BaseSettings)
- 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 annotateannotations (
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 annotateannotations (
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 objectclose_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 objectclose_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, workflow_id=None, rag=False)
Make an asynchronous request to POST a document for prediction.
- Parameters:
input_source (
Union[LocalInputSource,UrlInputSource]) – Input objectinclude_words (
bool, default:False) – Include raw OCR words in the responseclose_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.workflow_id (
Optional[str], default:None) – Workflow ID.rag (
bool, default:False) – If set, will enable Retrieval-Augmented Generation.
- 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 objectinclude_words (
bool, default:False) – Include raw OCR words in the responseclose_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 (str | None)
endpoint_name (str)
account_name (str)
version (str)
- class WorkflowEndpoint(settings)
Workflow endpoint.
- Parameters:
settings (WorkflowSettings)
- workflow_execution_post(input_source, options)
Sends the document to the workflow.
- Parameters:
input_source (
Union[LocalInputSource,UrlInputSource]) – The document/source file to use. Has to be created beforehand.options (
WorkflowOptions) – Options for the workflow.
- Returns:
-
settings:
WorkflowSettings
- class WorkflowSettings(api_key, workflow_id)
Settings class relating to workflow requests.
- Parameters:
api_key (str | None)
workflow_id (str)
- 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