tdjson
is a high-performance Python binding for TDLib's JSON interface. Outperforms ctypes
, and includes TDLib
for easy setup and use. Mainly created for Pytdbot
tdjson
is compatible with almost all Linux x86_64
distributions that use glibc 2.17+
. This includes most modern Linux distributions:
- Debian 8+
- Ubuntu 13.10+
- Fedora 19+
- RHEL 7+
You can install tdjson
directly from PyPI:
pip install tdjson
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))
# 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"]}))
print(result)
For more detailed examples, check out the examples folder.
MIT LICENSE