Skip to main content
Tryx

PyPI version Python License Docs

Language: English | 简体中文 | Bahasa Indonesia

Tryx is a Python automation library powered by Rust and PyO3. It provides a Python-friendly API on top of the whatsapp-rust crate, with async support, persistent sessions, and access to advanced WhatsApp Web protocol features.

Tryx is an independent project. It is not affiliated with WhatsApp, Meta, or their official products.

What Is Tryx?

Tryx helps Python developers build WhatsApp automation tools without writing Rust directly. The core protocol logic runs in Rust for performance, while the public interface stays ergonomic for Python applications.

Use Tryx when you need:

  • WhatsApp Web automation from Python.
  • Persistent login sessions with SQLite, PostgreSQL, or MySQL.
  • Async APIs for bots, workers, dashboards, and internal tools.
  • Access to contacts, groups, newsletters, status, privacy, profile, labels, comments, events, and lower-level protocol helpers.

Highlights

  • Rust core, Python API — protocol logic is implemented in Rust and exposed through PyO3.
  • Async first — designed for asyncio applications.
  • Persistent sessions — reuse device sessions through a database-backed store.
  • Broad API surface — exposes common and advanced client namespaces.
  • Typed Python stubs — includes .pyi files for better editor support.

Installation

pip install tryx

For local development:

git clone https://github.com/krypton-byte/tryx.git
cd tryx
git submodule update --init --recursive
uv sync --group dev
uv run maturin develop

Quick Start

import asyncio

from tryx.backend import SqliteStore
from tryx.client import Tryx, TryxClient
from tryx.events import EvMessage, EvPairingQrCode

backend = SqliteStore("whatsapp.db")
app = Tryx(backend)


@app.on(EvPairingQrCode)
async def on_pairing_qr(_client: TryxClient, event: EvPairingQrCode) -> None:
    print("Scan this QR code with WhatsApp:")
    print(event.code)


@app.on(EvMessage)
async def on_message(client: TryxClient, event: EvMessage) -> None:
    if (event.text or "").strip().lower() == "ping":
        await client.reply_text(event, "pong")


async def main() -> None:
    await app.run()


asyncio.run(main())

Client Namespaces

The runtime TryxClient object exposes several namespaces so the API stays organized:

Namespace Purpose
contact Contact lookup and contact-related helpers.
chat_actions Chat utilities such as mute, archive, pin, mark read, clear chat, and save contact.
groups Group creation, metadata, members, invites, membership requests, and admin settings.
community Community-related operations.
newsletter Newsletter info, messages, mute settings, edits, and revoke operations.
status Status posting, lookup, and related helpers.
chatstate Typing, recording, paused, and presence-style chat state updates.
blocking Block and unblock contacts.
polls Poll creation and voting helpers.
presence Presence subscriptions and availability updates.
privacy Privacy settings and related controls.
profile Profile name, status text, and picture operations.
labels Label management for chats and messages.
comments Comment-related protocol helpers.
events Event response helpers and event-oriented operations.
advanced Lifecycle waits, diagnostics, and lower-level protocol escape hatches.
voip Audio and video call management.

Storage Backends

Tryx supports three storage tiers:

Tier Backend Use case
Built-in SqliteStore("whatsapp.db") Local development and simple deployments.
Native FFI FfiStoreProtocol High-throughput external stores such as PostgreSQL.
Pure Python StoreBase subclass Custom async stores such as Redis, MongoDB, or DynamoDB.

SQLite is usually enough for local development. Native FFI or a custom Python backend is better when several workers or deployment environments need shared session state.

VoIP: Audio and Video Calls

Tryx provides a Rust-backed bridge for WhatsApp audio and video calls. Protocol handling, RTP/WebRTC, encryption, codecs, and call orchestration run in whatsapp-rust; Python supplies media through asynchronous source and sink adapters.

Media Contract

Media Contract
Audio Mono signed PCM16 little-endian, 16,000 Hz, 960 samples / 1,920 bytes per frame, 60 ms
Video H.264 Annex-B access unit represented by VideoFrame

Minimal Audio Adapters

from collections.abc import AsyncIterator
from tryx.media import AudioSink, AudioSource, validate_audio_frame


class Microphone(AudioSource):
    async def frames(self) -> AsyncIterator[bytes]:
        while True:
            frame = await read_microphone_frame()
            yield validate_audio_frame(frame)


class Speaker(AudioSink):
    async def write(self, frame: bytes) -> None:
        validate_audio_frame(frame)
        await play_speaker_frame(frame)

One-to-One Audio Call

from tryx.types import JID


async def start_audio_call(client, phone_number: str):
    peer = JID(phone_number + "@s.whatsapp.net")
    call = await client.voip.call(peer, Microphone(), Speaker())
    print("call started:", call.call_id, "phase:", call.phase)
    await call.set_muted(True)
    await call.set_muted(False)
    await call.wait_ended()

Video Call

from tryx.media import VideoPlayer


async def start_video_call(client, peer, video_sink):
    video_source = VideoPlayer(fps=15)
    video_source.play("sample.mp4")
    call = await client.voip.video_call(
        peer, Microphone(), Speaker(), video_source, video_sink
    )
    await call.wait_ended()
    video_source.stop()
call = await client.voip.group_call(
    peers=[peer_a, peer_b],
    audio_source=Microphone(),
    audio_sink=Speaker(),
)
await call.invite_participant(peer_c)
await call.ring_participant(peer_c)

linked = await client.voip.join_call_link(
    "https://call.whatsapp.com/your-token",
    "audio",
    Microphone(),
    Speaker(),
)

Native AudioPlayer

from tryx.media import AudioPlayer

player = AudioPlayer(buffer_frames=3)
player.play("intro.mp3", mode="replace")
call = await client.voip.call(peer, player, Speaker())
player.pause()
player.resume()
player.enqueue("next.wav")
player.skip()
player.clear_queue()
player.stop()

Development

cargo check
cargo test --lib
uv run pytest -q
uv run maturin develop
uv run maturin build --release

Project Layout

.
├── libs/whatsapp-rust/   # Rust protocol crate submodule
├── src/                  # Rust and PyO3 bindings
├── python/tryx/          # Python package and type stubs
├── examples/             # Example automation scripts
├── docs/                 # Documentation site
└── tests/                # Python test suite

License

This project is licensed under the terms of the MIT License.

Metadata

Release files for tryx 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tryx 2.0.0
File Size Uploaded Provenance Actions
tryx-2.0.0.tar.gz 18.0 MB Without provenance Details for tryx-2.0.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tryx 2.0.0
File Actions
tryx-2.0.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for tryx-2.0.0-cp38-abi3-win_amd64.whl
tryx-2.0.0-cp38-abi3-win32.whl CPython 3.8 abi3 Windows x86-32 Details for tryx-2.0.0-cp38-abi3-win32.whl
tryx-2.0.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for tryx-2.0.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
tryx-2.0.0-cp38-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl CPython 3.8 abi3 Linux glibc 2.17+ IBM System/390x Details for tryx-2.0.0-cp38-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl
tryx-2.0.0-cp38-abi3-manylinux2014_i686.manylinux_2_17_i686.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-32 Details for tryx-2.0.0-cp38-abi3-manylinux2014_i686.manylinux_2_17_i686.whl
tryx-2.0.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for tryx-2.0.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
tryx-2.0.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for tryx-2.0.0-cp38-abi3-macosx_11_0_arm64.whl
tryx-2.0.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for tryx-2.0.0-cp38-abi3-macosx_10_12_x86_64.whl
tryx-2.0.0-cp38-abi3-android_24_x86_64.whl CPython 3.8 abi3 Android API level 24+ x86-64 Details for tryx-2.0.0-cp38-abi3-android_24_x86_64.whl
tryx-2.0.0-cp38-abi3-android_24_arm64_v8a.whl CPython 3.8 abi3 Android API level 24+ ARM64 v8a Details for tryx-2.0.0-cp38-abi3-android_24_arm64_v8a.whl

Total release size: 162.3 MB

Release files / tryx-2.0.0.tar.gz

Download URL tryx-2.0.0.tar.gz
Size 18.0 MB
Tags Source
SHA-256 checksum
How to use checksums
5d5ef207aafef08d0b016cc9a77cfff031e1f6af6c584dfd3e573ce60614348d
BLAKE2b-256 checksum
How to use checksums
3ca7fc67c8569cb044126bc2af3b8650de724fe8276047ee28235de1a5e8cd6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-win_amd64.whl

Download URL tryx-2.0.0-cp38-abi3-win_amd64.whl
Size 16.6 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
195cc4035b7263217bf581a512eb642a01872f06ba460edeed121fa6b699f98f
BLAKE2b-256 checksum
How to use checksums
ff48602261a2fa8567cead02ba133d5c29f6afb08df459632f2714881cae45ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-win32.whl

Download URL tryx-2.0.0-cp38-abi3-win32.whl
Size 14.0 MB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
477e4a8f1646611e5859f7cfa27d159ca6eda0e19d040136b87ca90b74fb088b
BLAKE2b-256 checksum
How to use checksums
ab39a81a7cccc98ee5135e907d90653dc0513fc87bf3cd22b16cff819ddcb0e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL tryx-2.0.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 14.4 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7867c63cdbe5d27bdae1954686612f31f21358ff036bf23b756cb465aab250bd
BLAKE2b-256 checksum
How to use checksums
55eb17ea5db9a13a11c17af425b7f7012d84771d49e6d5bde7d81f9685ca281d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl

Download URL tryx-2.0.0-cp38-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl
Size 14.7 MB
Tags CPython 3.8 Linux glibc 2.17+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
b9ecaa024569fcfb672c6a713403bbacbd056bbbf0bf436b6efafb36aa5e763f
BLAKE2b-256 checksum
How to use checksums
093bc43f625159724fd52b9094ed5c76f5766aafe0a8672c2d403022bc7ab1f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-manylinux2014_i686.manylinux_2_17_i686.whl

Download URL tryx-2.0.0-cp38-abi3-manylinux2014_i686.manylinux_2_17_i686.whl
Size 14.8 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-32 abi3
SHA-256 checksum
How to use checksums
f6f74f460d9a59f4f80e34a3aaf8b25d76988f875f23b9da0af935a4f6375cd5
BLAKE2b-256 checksum
How to use checksums
63f4ba9953fecd953924454cf4504072c35543c1fa2f80a602e6f5c32cd0d04b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL tryx-2.0.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 13.8 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
39875d7fce3b04c1969d4f8d21750ca080e7e4807a4737056c0c489c6402f4de
BLAKE2b-256 checksum
How to use checksums
ca03b8faac3137c736bc12a9586872b39933f4a114eed51da6c872b821ffb4d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL tryx-2.0.0-cp38-abi3-macosx_11_0_arm64.whl
Size 13.4 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2bfe60cfb88427b7d2ad7b9c21e3140664e56893ec30a489d80b2e396199b749
BLAKE2b-256 checksum
How to use checksums
2b7cb59c85667113f8b67e57ea50a86b2cc1cf6c7f5e57b21866366e4ca4bbfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL tryx-2.0.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 14.1 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
653b5277f0d6ac36f3503e13ad5cfd3c2cfae031fba6030094d7089ac317a60d
BLAKE2b-256 checksum
How to use checksums
87f38ade7a5be085d7b90e76b937498df8e0aa000cb5abc9159fd816c9bc2493
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-android_24_x86_64.whl

Download URL tryx-2.0.0-cp38-abi3-android_24_x86_64.whl
Size 14.6 MB
Tags Android API level 24+ x86-64 CPython 3.8 abi3
SHA-256 checksum
How to use checksums
f0df8be6c9179fc7b5ca28cfc23993cd732b30adf8acb2593896a9e84e59efc9
BLAKE2b-256 checksum
How to use checksums
b4fe09d0eac13210211f14c332c3502a42af506179ae50d23d4996819ce2bd3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tryx-2.0.0-cp38-abi3-android_24_arm64_v8a.whl

Download URL tryx-2.0.0-cp38-abi3-android_24_arm64_v8a.whl
Size 13.9 MB
Tags Android API level 24+ ARM64 v8a CPython 3.8 abi3
SHA-256 checksum
How to use checksums
316ce25625d1fc8e95e92fa74a72b06821d136a7b19a2f1890395a37d627f472
BLAKE2b-256 checksum
How to use checksums
4dc1d2320241a9b17ca6e3a275d0085e03e20dbdc69d72f6918ba3250b0e0a55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for tryx 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page