Python Reference

Generating RSA Keys

reusable.email.generate_keys(public_exponent=65537, key_size=2048) tuple[bytes, bytes]

Generate a pair of RSA public and private keys.

Parameters:
  • public_exponent (int) – Public exponent for the key generation. Default is 65537.

  • key_size (int) – Size of the key in bits. Default is 2048.

Returns:

A tuple containing the public key and private key in PEM format as bytes.

Return type:

tuple[bytes, bytes]

Synchronous API

class reusable.email.Sync(authorization: str, private_key: bytes | None = None)[source]

Bases: object

Manages a synchronized session with the API.

Methods

General inboxes

view_inbox(alias: str, after: str | None = None) list[reusable.email.types.Email] | Response[source]

View the content of an inbox.

fetch_email_body(alias: str, email_id: str) str | Response[source]

Fetch a specific email’s body from the inbox.

delete_email(alias: str, email_id: str) bool | Response[source]

Delete a specific email from the inbox.

Encrypted inboxes

create_encrypted_inbox(alias: str, public_key: bytes) bool | Response[source]

Create a new encrypted inbox.

view_encrypted_inbox(alias: str, after: str | None = None) list[reusable.email.types.Email] | Response[source]

View the content of an inbox.

fetch_encrypted_email(alias: str, email_id: str) Email | Response[source]

Fetch a specific email from the inbox.

delete_encrypted_email(alias: str, email_id: str) bool | Response[source]

Delete a specific email from the inbox.

create_encrypted_inbox(alias: str, public_key: bytes) bool | Response[source]

Create a new encrypted inbox.

delete_email(alias: str, email_id: str) bool | Response[source]

Delete a specific email from the inbox.

delete_encrypted_email(alias: str, email_id: str) bool | Response[source]

Delete a specific email from the inbox.

fetch_email_body(alias: str, email_id: str) str | Response[source]

Fetch a specific email’s body from the inbox.

fetch_encrypted_email(alias: str, email_id: str) Email | Response[source]

Fetch a specific email from the inbox.

generate_session(authorization: str) None[source]

Initialize the API session with the necessary headers.

static json_or_text(response: Response) Dict[str, Any] | str[source]

Extract JSON or text response from an HTTP response.

request(route: Route, headers: Dict[str, str] | None = None, params: Dict[str, str] | None = None, json: Dict[str, Any] | None = None, data: Dict[str, Any] | None = None) Response[source]

Send an HTTP request based on the given route and parameters.

view_encrypted_inbox(alias: str, after: str | None = None) list[reusable.email.types.Email] | Response[source]

View the content of an inbox.

view_inbox(alias: str, after: str | None = None) list[reusable.email.types.Email] | Response[source]

View the content of an inbox.

Asynchronous API

class reusable.email.Async(authorization: str, private_key: bytes | None = None)[source]

Bases: object

Manages an asynchronous session with the API.

Methods

Session related methods

async generate_session() None[source]

Initialize the API session with the necessary headers.

General inboxes

async view_inbox(alias: str, after: str | None = None) list[reusable.email.types.Email] | ClientResponse[source]

View the content of an inbox.

async fetch_email_body(alias: str, email_id: str) str | ClientResponse[source]

Fetch a specific email from the inbox.

async delete_email(alias: str, email_id: str) bool | ClientResponse[source]

Delete a specific email from the inbox.

Encrypted inboxes

async create_encrypted_inbox(alias: str, public_key: bytes) bool | ClientResponse[source]

Create a new encrypted inbox.

async view_encrypted_inbox(alias: str, after: str | None = None) list[reusable.email.types.Email] | ClientResponse[source]

View the content of an inbox.

async fetch_encrypted_email(alias: str, email_id: str) Email | ClientResponse[source]

Fetch a specific email from the inbox.

async delete_encrypted_email(alias: str, email_id: str) bool | ClientResponse[source]

Delete a specific email from the inbox.

async close() None[source]

Close the session.

async create_encrypted_inbox(alias: str, public_key: bytes) bool | ClientResponse[source]

Create a new encrypted inbox.

async delete_email(alias: str, email_id: str) bool | ClientResponse[source]

Delete a specific email from the inbox.

async delete_encrypted_email(alias: str, email_id: str) bool | ClientResponse[source]

Delete a specific email from the inbox.

async fetch_email_body(alias: str, email_id: str) str | ClientResponse[source]

Fetch a specific email from the inbox.

async fetch_encrypted_email(alias: str, email_id: str) Email | ClientResponse[source]

Fetch a specific email from the inbox.

async generate_session() None[source]

Initialize the API session with the necessary headers.

async static json_or_text(response: ClientResponse) Dict[str, Any] | str[source]

Extract JSON or text response from an HTTP response.

async request(route: Route, headers: Dict[str, str] | None = None, params: Dict[str, str] | None = None, json: Dict[str, Any] | None = None, data: Dict[str, Any] | None = None) ClientResponse[source]

Send an asynchronous HTTP request based on the given route and parameters.

async view_encrypted_inbox(alias: str, after: str | None = None) list[reusable.email.types.Email] | ClientResponse[source]

View the content of an inbox.

async view_inbox(alias: str, after: str | None = None) list[reusable.email.types.Email] | ClientResponse[source]

View the content of an inbox.