Skip to content

AYMENJD/tdjson

Repository files navigation

tdjson Version TDLib version Python Compatibility Downloads

tdjson is a high-performance Python binding for TDLib JSON interface.

By bundling pre-built TDLib binaries, it eliminates the effort for manual compilation and offers performance advantage over traditional ctypes wrappers, making it a reliable core for projects like Pytdbot

Buy me a Cup of TON

Compatibility

tdjson is compatible with the following platforms:

  • Linux (x64 and ARM64)

    • Requires glibc 2.17+.
    • Debian 8+, Ubuntu 13.10+, Fedora 19+, RHEL 7+
  • Windows (x64) — Windows 7+

  • macOS (M-series) — macOS 11+

Installation

You can install tdjson directly from PyPI:

pip install tdjson

Usage

Here’s a quick example to get you started:

import json
import tdjson

# Create a new TDLib client
client_id = tdjson.td_create_client_id()

# Send a request to TDLib
request = {"@type": "getOption", "name": "version"}
tdjson.td_send(client_id, json.dumps(request).encode("utf-8"))

# Receive updates or responses
response = tdjson.td_receive(10.0)
print(response)

# Synchronously execute a TDLib request
result = tdjson.td_execute(
    json.dumps(
        {
            "@type": "getTextEntities",
            "text": "@telegram /test_command https://telegram.org telegram.me",
            "@extra": ["5", 7.0, "a"],
        }
    ).encode("utf-8")
)
print(result)

For more detailed examples, check out the examples folder.

License

MIT LICENSE

About

High-performance Python binding for TDLib JSON interface

Topics

Resources

License

Stars

Watchers

Forks