https://github.com/aymenjd/tdjson
High-performance Python binding for TDLib JSON interface
https://github.com/aymenjd/tdjson
nanobind python tdlib telegram
Last synced: about 2 months ago
JSON representation
High-performance Python binding for TDLib JSON interface
- Host: GitHub
- URL: https://github.com/aymenjd/tdjson
- Owner: AYMENJD
- License: mit
- Created: 2025-02-09T22:05:17.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-03-07T13:53:01.000Z (3 months ago)
- Last Synced: 2025-03-24T09:36:32.292Z (2 months ago)
- Topics: nanobind, python, tdlib, telegram
- Language: C++
- Homepage:
- Size: 25.4 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tdjson [](https://pypi.org/project/Tdjson) [](https://github.com/tdlib/td) [](https://pepy.tech/project/tdjson)
`tdjson` is a high-performance Python binding for [TDLib](https://github.com/tdlib/td)'s JSON interface. Outperforms `ctypes`, and **includes** `TDLib` for easy setup and use. Mainly created for [Pytdbot](https://github.com/pytdbot/client)
## Compatibility
`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+## Installation
You can install `tdjson` directly from PyPI:
```bash
pip install tdjson
```## Usage
Here’s a quick example to get you started:
```python
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](https://github.com/AYMENJD/tdjson/blob/main/examples) folder.
## License
MIT [LICENSE](https://github.com/AYMENJD/tdjson/blob/main/LICENSE)