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:
    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.4.2

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.4.2
File Size Uploaded
tryx-1.4.2.tar.gz 10.5 MB Details

Built distributions (wheels)

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

Total release size: 135.7 MB

Release files / tryx-1.4.2.tar.gz

Download URL tryx-1.4.2.tar.gz
Size 10.5 MB
Tags Source
SHA-256 checksum
How to use checksums
a8fcef853704f3ac89a0b7b1d717fc279d55fd33a8c5fb51152f130afb8e3613
BLAKE2b-256 checksum
How to use checksums
6f8b85da99a07414289225ad864a42bd6030fbf2554be1ec6a5e0f5949e4db53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-win_amd64.whl

Download URL tryx-1.4.2-cp38-abi3-win_amd64.whl
Size 14.2 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c4b2572b080d824253167b1c8895f1fea083f5d0cb99d2c207a1be3558792c51
BLAKE2b-256 checksum
How to use checksums
b2e83a7c2c8e532ad19893dc11b3aa926f894c4eb577530a0b1bc691adb8f4e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-win32.whl

Download URL tryx-1.4.2-cp38-abi3-win32.whl
Size 12.1 MB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
cfbbb310b8e09d6452becdd4ba643198dc21e63be1e6736146bdd67de4cbc6bf
BLAKE2b-256 checksum
How to use checksums
23810ce82f1dae36e399a1530fd6282b5d50a326b1a46274ddec6d95370e240c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tryx-1.4.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 12.5 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
465e9ba9f40f05e37d3411d27f40859f714de561ec0143dd4c41da56db61ed00
BLAKE2b-256 checksum
How to use checksums
f0f52eb446eab072d80b0cc3e043270bd6cc36db4d64e0f60f7ed534c87b0c46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL tryx-1.4.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 12.8 MB
Tags CPython 3.8 Linux glibc 2.17+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
0deb3f0806daeff0e0b43092b2d106cdc2d15182432434b155515a54bbd2bd36
BLAKE2b-256 checksum
How to use checksums
67158344c3f375bb6761c88291cdb9d26a5252e221fd42c47bf3b68902778bde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL tryx-1.4.2-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Size 12.9 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-32 abi3
SHA-256 checksum
How to use checksums
beaecd40a227a1337ff36e45644372dee69714c78f15116e363c00f1b75ab8a9
BLAKE2b-256 checksum
How to use checksums
7c5a0370f920b5bad4bb57c1d3eb2556da885a47f8a865d0efacc2196afca682
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL tryx-1.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 12.0 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
67da540c6f53cf6e9b0fff0814f57a5941e5774fc6236effe56789137761954b
BLAKE2b-256 checksum
How to use checksums
73e6cfcd441f3e3bbef8ee4346d6a615defd24d81a9ed26db81794e78f0ebc40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-macosx_11_0_arm64.whl

Download URL tryx-1.4.2-cp38-abi3-macosx_11_0_arm64.whl
Size 11.6 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
70a661773f3f281211901b0b217600752793a26e48265e67e2791038c2911c12
BLAKE2b-256 checksum
How to use checksums
b01743dffe5cee8d94b102ccb6b166b1ac6f1547abe631bbebd561c49b271638
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-macosx_10_12_x86_64.whl

Download URL tryx-1.4.2-cp38-abi3-macosx_10_12_x86_64.whl
Size 12.3 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
df74164d48b69f3ebd7fedd8f24dd7c19bbbbbf928701f10378263fd207ad77b
BLAKE2b-256 checksum
How to use checksums
7330c85c187ffa9a9d83e7e9505cdbf1e1b8c0bbbb3d01006091e7617d3765ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-android_24_x86_64.whl

Download URL tryx-1.4.2-cp38-abi3-android_24_x86_64.whl
Size 12.7 MB
Tags Android API level 24+ x86-64 CPython 3.8 abi3
SHA-256 checksum
How to use checksums
326d0142344aa2f41f3588c39624330f581e3417c1dd4d6d6b8ccb91268cac15
BLAKE2b-256 checksum
How to use checksums
c7353cff26933142c82105d954ec4d286739566ad8609f72ce4ae1f0cae42b69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.4.2-cp38-abi3-android_24_arm64_v8a.whl

Download URL tryx-1.4.2-cp38-abi3-android_24_arm64_v8a.whl
Size 12.1 MB
Tags Android API level 24+ ARM64 v8a CPython 3.8 abi3
SHA-256 checksum
How to use checksums
fa3574b4417931be2c8db71aa643f142c564aad357837f2df8d0311651f9c437
BLAKE2b-256 checksum
How to use checksums
92bd1e1dadfc388219e018bd933bc4186bb1a24448257e08e3bd3544a293f5a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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

1.5.0

11 release files

This release

1.4.2 This release

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