parseur

Submodules

Classes

Config

Document

Document resource providing class-based API access.

DocumentOrderKey

Enumeration of supported document sorting keys.

ParseurEvent

Enumeration of supported Parseur webhook event types.

Mailbox

MailboxOrderKey

Enumeration of supported mailbox sorting keys.

DocumentStatus

Enum for Parseur document processing statuses.

Webhook

Functions

to_json(data[, indent, sort_keys, ensure_ascii])

Serialize a Python object to a JSON-formatted string with ISO datetime support.

Package Contents

class parseur.Config(config_path: str)[source]
config_path
api_key = None
api_base = None
load()[source]
save()[source]
class parseur.Document[source]

Document resource providing class-based API access.

classmethod from_response(data: Dict) Dict[source]

Validate and deserialize a single document dict.

classmethod log_from_response(data: Dict) Dict[source]

Validate and deserialize a single document log dict.

classmethod upload_from_response(data: Dict) Dict[source]

Validate and deserialize a single document log dict.

classmethod iter(mailbox_id: int, *, search: str | None = None, order_by: DocumentOrderKey | None = None, ascending: bool = True, received_after: datetime.datetime | None = None, received_before: datetime.datetime | None = None, with_result: bool = False) Iterable[Dict][source]

Yield all documents in a mailbox with pagination and filtering.

Parameters:
  • mailbox_id – The mailbox ID to retrieve documents from.

  • search (str) –

    Search string to filter documents. The search query parameter searches the following properties:

    • document id (exact match)

    • document name

    • template name

    • from, to, cc, and bcc email addresses

    • document metadata header

  • order_by (DocumentOrderKey) – Enum value specifying the sorting field.

  • ascending (bool) – Whether to sort in ascending order (True) or descending order (False).

  • received_after (datetime.datetime) – Filter for documents received after this date (converted to UTC YYYY-MM-DD).

  • received_before (datetime.datetime) – Filter for documents received before this date (converted to UTC YYYY-MM-DD).

  • with_result (bool) – Whether to include the parsed result in the returned documents.

Yield dict:

Each yielded dictionary represents a document.

classmethod list(mailbox_id: int, *, search: str | None = None, order_by: DocumentOrderKey | None = None, ascending: bool = True, received_after: datetime.datetime | None = None, received_before: datetime.datetime | None = None, with_result: bool = False) List[Dict][source]
classmethod retrieve(document_id: str) Dict[source]

Retrieve document details, deserialized.

classmethod reprocess(document_id: str) Dict[source]
classmethod skip(document_id: str) Dict[source]
classmethod copy(document_id: str, target_mailbox_id: int) Dict[source]
classmethod logs(document_id: str) List[Dict][source]
classmethod delete(document_id: str) bool[source]
classmethod upload_file(mailbox_id: int, file_path: str) Dict[source]
classmethod batch_upload_files(file_paths: List[str], mailbox_id: int) Iterable[Dict][source]
classmethod upload_folder(mailbox_id: int, folder_path: str) Iterable[Dict][source]
classmethod upload_text(recipient: str, subject: str, sender: str | None = None, body_html: str | None = None, body_plain: str | None = None) Dict[source]
class parseur.DocumentOrderKey[source]

Bases: str, enum.Enum

Enumeration of supported document sorting keys.

Used with the order_by parameter to specify sorting in list_documents and yield_documents.

Members:

  • NAME: Sort by document name.

  • CREATED: Sort by created/received date.

  • PROCESSED: Sort by processed date.

  • STATUS: Sort by document status.

NAME = 'name'
CREATED = 'created'
PROCESSED = 'processed'
STATUS = 'status'
class parseur.ParseurEvent[source]

Bases: str, enum.Enum

Enumeration of supported Parseur webhook event types.

Use these values when registering webhooks to specify which event to listen for.

Members:

  • DOCUMENT_PROCESSED: Document processed successfully.

  • DOCUMENT_PROCESSED_FLATTENED: Document processed as flat data.

  • DOCUMENT_TEMPLATE_NEEDED: Document processing failed (template needed).

  • DOCUMENT_EXPORT_FAILED: Export of the document failed.

  • TABLE_PROCESSED: A table field row was processed.

  • TABLE_PROCESSED_FLATTENED: A table field row (flattened) was processed.

DOCUMENT_PROCESSED = 'document.processed'
DOCUMENT_PROCESSED_FLATTENED = 'document.processed.flattened'
DOCUMENT_TEMPLATE_NEEDED = 'document.template_needed'
DOCUMENT_EXPORT_FAILED = 'document.export_failed'
TABLE_PROCESSED = 'table.processed'
TABLE_PROCESSED_FLATTENED = 'table.processed.flattened'
is_table_event() bool[source]
class parseur.Mailbox[source]
classmethod from_response(data: Dict) Dict[source]

Deserialize a single mailbox API response.

Parameters:

data – Raw API response dictionary.

Returns:

Validated and transformed mailbox dictionary.

classmethod iter(*, search: str | None = None, order_by: MailboxOrderKey | None = None, ascending: bool = True) Iterable[Dict][source]

Yield all mailboxes with pagination and optional filtering or sorting.

classmethod list(*, search: str | None = None, order_by: MailboxOrderKey | None = None, ascending: bool = True) List[Dict[str, Any]][source]

Retrieve all mailboxes as a list.

classmethod retrieve(mailbox_id: int) Dict[str, Any][source]

Retrieve a single mailbox by ID.

classmethod schema(mailbox_id: int) Dict[str, Any][source]

Get the schema for a mailbox.

class parseur.MailboxOrderKey[source]

Bases: str, enum.Enum

Enumeration of supported mailbox sorting keys.

Used with the order_by parameter to specify sorting in Mailbox.list() and Mailbox.iter().

NAME = 'name'
DOCUMENT_COUNT = 'document_count'
TEMPLATE_COUNT = 'template_count'
PARSEDOK_COUNT = 'PARSEDOK_count'
PARSEDKO_COUNT = 'PARSEDKO_count'
QUOTAEXC_COUNT = 'QUOTAEXC_count'
EXPORTKO_COUNT = 'EXPORTKO_count'
class parseur.DocumentStatus[source]

Bases: str, enum.Enum

Enum for Parseur document processing statuses.

INCOMING = 'INCOMING'
ANALYZING = 'ANALYZING'
DELETED = 'DELETED'
PROGRESS = 'PROGRESS'
PARSEDOK = 'PARSEDOK'
PARSEDKO = 'PARSEDKO'
QUOTAEXC = 'QUOTAEXC'
SKIPPED = 'SKIPPED'
SPLIT = 'SPLIT'
EXPORTKO = 'EXPORTKO'
TRANSKO = 'TRANSKO'
INVALID = 'INVALID'
parseur.to_json(data, indent=2, sort_keys=True, ensure_ascii=False)[source]

Serialize a Python object to a JSON-formatted string with ISO datetime support.

This function uses the custom ISODateJSONEncoder to automatically convert datetime.datetime objects to ISO 8601 strings.

Parameters:
  • data – The data to serialize (dict, list, etc.).

  • indent – Number of spaces to indent in the output JSON. Default is 2.

  • sort_keys – Whether to sort the dictionary keys in the output. Default is True.

  • ensure_ascii – Whether to escape non-ASCII characters. Default is False.

Returns:

A JSON-formatted string.

class parseur.Webhook[source]
classmethod from_response(data: Dict) Dict[source]

Deserialize a webhook API response.

Parameters:

data – Raw API response dictionary.

Returns:

Deserialized webhook dictionary.

classmethod create(event: parseur.event.ParseurEvent, target_url: str, mailbox_id: int | None = None, table_field_id: str | None = None, headers: Dict[str, str] | None = None, name: str | None = None) Dict[str, Any][source]

Create a new custom webhook for Parseur.

Parameters:
  • event – Webhook event type (document or table event).

  • target_url – The URL to send webhook POSTs to.

  • mailbox_id – Mailbox ID (required for document events).

  • table_field_id – Table field ID (required for table events, e.g. “PF12345”).

  • headers – Optional custom HTTP headers.

  • name – Optional custom name for the webhook.

Returns:

The created webhook object as a dictionary.

classmethod retrieve(webhook_id: int) Dict[str, Any][source]

Retrieve a webhook from the account.

Parameters:

webhook_id – ID of the webhook to delete.

Returns:

The updated mailbox object as a dictionary.

classmethod delete(webhook_id: int) bool[source]

Delete a webhook from the account.

Parameters:

webhook_id – ID of the webhook to delete.

Returns:

True if deletion was successful.

classmethod enable(mailbox_id: int, webhook_id: int) Dict[str, Any][source]

Enable an existing webhook for a given mailbox.

Parameters:
  • mailbox_id – ID of the mailbox.

  • webhook_id – ID of the webhook to enable.

Returns:

The updated mailbox object as a dictionary.

classmethod pause(mailbox_id: int, webhook_id: int) Dict[str, Any][source]

Pause (disable) an existing webhook for a given mailbox.

Parameters:
  • mailbox_id – ID of the mailbox.

  • webhook_id – ID of the webhook to pause.

Returns:

The updated mailbox object as a dictionary.

classmethod list() List[Dict[str, Any]][source]

Retrieve all webhooks as a list.

classmethod iter() Iterable[Dict[str, Any]][source]

Yield all webhooks registered on the account.