Skip to main content

chat-xdk Python bindings

Python bindings for the X Chat SDK — encryption for X Direct Messages.

Install

pip install chatxdk

The PyPI distribution is chatxdk; import it as chat_xdk.

Architecture

Python (chat_xdk) → PyO3 → chat-xdk-core (Rust)

Prerequisites

  • Python 3.10+
  • Rust (stable) and maturin

Setup

From source (editable install):

cd crates/pyo3
pip install maturin
maturin develop

Release wheel:

maturin build --release
pip install target/wheels/*.whl

Quick Start

from chat_xdk import Chat

chat = Chat(config_json)
chat.unlock("2580")
# Or load a local key blob + its registered version instead of Juicebox:
# chat.import_keys(private_key_bytes, version=registered_key_version)

# Set the session once: your user id + registered signing-key version,
# the opt-in conversation-key cache, and the participants' signing keys.
# Each signing-key entry must include the identity public key and its binding
# signature so the SDK can verify the signing key is authentic.
chat.set_identity("111", "v1")
chat.set_cache_keys(True)
chat.set_signing_keys([
    {
        "user_id": "111",
        "public_key_version": "v1",
        "public_key": "BASE64...",
        "identity_public_key": "BASE64...",
        "identity_public_key_signature": "BASE64...",
    },
    {
        "user_id": "222",
        "public_key_version": "v1",
        "public_key": "BASE64...",
        "identity_public_key": "BASE64...",
        "identity_public_key_signature": "BASE64...",
    },
])

# Initial load — batch decrypt with automatic key extraction. Signing keys
# come from the store; the verified conversation keys populate the cache.
result = chat.decrypt_events(raw_events)

for dm in result["messages"]:
    if dm["event"]["type"] == "Message":
        print(dm["event"]["sender_id"], dm["event"]["content"]["text"])

# Individual events after the initial load: conversation keys resolve from
# the cache and signing keys from the store (pass either explicitly to
# override).
event = chat.decrypt_event(new_event_b64)

# Sending resolves the identity and conversation key from the session too.
payload = chat.encrypt_message(event["conversation_id"], "hi!")
# Reply / react by handing back the raw event being answered.
reply = chat.encrypt_reply(event["conversation_id"], "pong", new_event_b64)
reaction = chat.encrypt_add_reaction(new_event_b64, "👍")

API

See the Python column of the unified tables in docs/API.md for the full method list, parameters, and return types.

Security limitations

The underlying protocol provides no forward secrecy and no post-compromise security: compromise of an identity private key exposes all conversation keys ever encrypted to that public key — and therefore all past and future messages in those conversations. Key rotation does not retroactively protect messages encrypted under a previous key. See docs/CRYPTO.md — Known Limitations.

License

MIT — see the repo LICENSE. Third-party notices: THIRD_PARTY_NOTICES.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

chatxdk-0.5.0-cp310-abi3-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

chatxdk-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

chatxdk-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

chatxdk-0.5.0-cp310-abi3-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

chatxdk-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file chatxdk-0.5.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: chatxdk-0.5.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for chatxdk-0.5.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 282859fcbbd56346a054c7f334a0d9b0159050ba10b07123cc53dda6bb80010e
MD5 61fb8eac2be89c42f624882237ce64ed
BLAKE2b-256 21dc1b2d88aacf854093e6f965e48c4184cb2d905be6426fed562100fcd7a061

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.5.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatxdk-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chatxdk-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1abf62b5a9c1e1cec8bb52e188a34d6ba2b6abdee2d2fb791a488c4100279749
MD5 de57eaf750bd26a22133e44470ffe552
BLAKE2b-256 9e09b0c5d659ca2cb3893d95be9f47828a0e227d9c8b86c2a14a004164e23311

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatxdk-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for chatxdk-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 64e3ae38a35acdd461671b311c2babaa3a825a8be3610af544809e809c5e847a
MD5 d535327aa91eaacb6ffca85dd6493009
BLAKE2b-256 095b8a6c7573571220eb75aaf6be9c2c9dd6a83dc47de8e0ea8f80ca082eb500

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatxdk-0.5.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chatxdk-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b0a261e9668bf338446c5da7e438618af7173909ec88edac89877b1b55f49585
MD5 afe02f9dde2f4a0e7caa15e1529893c8
BLAKE2b-256 f1cbf5198af49fa5696e8405e8b26d392adeb6e45b0c847434ffb7db1a17c97c

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.5.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatxdk-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for chatxdk-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d7136b001ee3f00666b928b3b24c7af8365babcb00579a6585edd4376b86e994
MD5 39b9a7bd834a3131ab07ed7a2b5eb38a
BLAKE2b-256 d1c8cfc020758fef07cf2d943399ca3bf50c1c5a08ce74f09fc0c1b72a9d0b54

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.0 This release

5 files

0.4.3

5 files

0.4.2

5 files

0.4.1

5 files

0.4.0

5 files

0.2.1

5 files

0.2.0

5 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