Skip to main content
Tryx

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:
    text = (event.data.get_text() or "").strip()
    if text.lower() == "ping":
        await client.send_text(
            event.data.message_info.source.chat, "pong", quoted=event
        )


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)
    call.set_muted(True)
    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 1.5.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 1.5.0
File Size Uploaded
tryx-1.5.0.tar.gz 16.2 MB Details

Built distributions (wheels)

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

Total release size: 142.7 MB

Release files / tryx-1.5.0.tar.gz

Download URL tryx-1.5.0.tar.gz
Size 16.2 MB
Tags Source
SHA-256 checksum
How to use checksums
5132df37230c49d7284643e0158afbf6aa369ab560234bd14e89b892db1234cd
BLAKE2b-256 checksum
How to use checksums
3a80f4df731511f717a7f6fc0ac04bf9c443ce9ecd57c2ebeac3740cab4a5c47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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

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

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

Download URL tryx-1.5.0-cp38-abi3-win32.whl
Size 12.2 MB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
5dfaf4ce9e72d1459d17011b7effcb0476021d3331ba18aea563b36b5bf18fea
BLAKE2b-256 checksum
How to use checksums
513b8980e56345098817c163a83d51a910cdfa816134010daf2b7632b91ddb93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Release history Release notifications | RSS feed

This release

1.5.0 This release

11 release files

1.4.2

11 release files

1.3.2

11 release files

1.1.1

11 release files

1.0.3

11 release files

0.6.4

32 release files

0.6.3

32 release files

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