Skip to content

Store

store

Session state storage.

SessionStore

SessionStore(path: Path | str)

Storage for the state of a single WhatsApp session.

All operations are serialized by a single asyncio.Lock: SQLite allows one writer, and the shared lock also prevents reading uncommitted state over the same connection.

delete_sessions_for_user async

delete_sessions_for_user(user: str) -> None

Drop every device session of one account, e.g. after a retry request.

put_lid_mapping async

put_lid_mapping(pn_jid: str, lid_jid: str) -> None

Phone-number JID -> LID JID, as shared by the phone.

upsert_peer async

upsert_peer(
    jid: str,
    kind: str,
    *,
    phone: str | None = None,
    push_name: str | None = None,
    contact_name: str | None = None,
    subject: str | None = None,
) -> None

Insert or refine a peer; existing values are never wiped by a None.

get_messages async

get_messages(
    chat_jid: str,
    *,
    limit: int = 100,
    before_timestamp: int | None = None,
) -> list[dict[str, Any]]

Newest first; before_timestamp walks towards older messages.

list_chats async

list_chats(*, limit: int = 100) -> list[dict[str, Any]]

Peers that have messages, newest conversation first.

set_reaction async

set_reaction(
    chat_jid: str,
    message_id: str,
    sender_jid: str,
    text: str,
    *,
    timestamp: int | None = None,
) -> None

An empty text removes that sender's reaction.