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.4.3-cp310-abi3-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

chatxdk-0.4.3-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.4.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10+macOS 11.0+ ARM64

chatxdk-0.4.3-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.4.3-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: chatxdk-0.4.3-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/6.1.0 CPython/3.13.14

File hashes

Hashes for chatxdk-0.4.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 df80d4fbc2e4c8c9455510ac6ffe2e81937044166f53e34f1287fcb56cc23357
MD5 fac056ca9d4bdd75d9b1f178426f0b17
BLAKE2b-256 3b2fa57dd84ac2c12baac4b421d880b76e36f0f6646c9ee4c35d24dc98b8c422

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.4.3-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.4.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chatxdk-0.4.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54db1b93b7feeb754a0fbea64a8b29d5234f7e9167d3de54162d81b7dd402c3b
MD5 98a69e20ad3c8113e11e241c88f9adab
BLAKE2b-256 29a8f360793651be9dd70b81930e066429a6713287c34827372e5ef5d3ff2b25

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.4.3-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.4.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for chatxdk-0.4.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 89d20b116cd945e00c0d3892d57a388d27364e3cc8ce6a02dbacbfb189ca6cdf
MD5 6b04bd0cdb815658136868719960c12a
BLAKE2b-256 cf19f8a53facfaeb61475dc1e586c53dffd34558d52e408b9d11c6a098608e30

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.4.3-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.4.3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chatxdk-0.4.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d41b13116e9cbfc81a60be715f4449d3dd4ba36abf6cddd556bf54e6360fff6
MD5 d6ee4e1e5489044582a96de76174a647
BLAKE2b-256 bd05b89a0fbce9f4f6a71325745b8913aa03667ae5a4284d58d324997ebb0ea4

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.4.3-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.4.3-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for chatxdk-0.4.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a6d9d63e073c17e2c27bce8fa69df28bbda7fa76c30e8cf0466aeffd6a55d550
MD5 834b7ad55f40838dc107158f1978de57
BLAKE2b-256 c2fcce97f22994ff112ccb95b37022bdfd48dee24d6d6f81ee7b01f3c4d22121

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.4.3-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

0.5.0

5 files

This release

0.4.3 This release

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