Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

AYMENJD/tdjson

Open more actions menu

Repository files navigation

tdjson

Version Python Versions Downloads

tdjson provides fast, native Python bindings for the JSON interface of TDLib.

It bundles prebuilt TDLib binaries, eliminating manual compilation and making it a reliable foundation for projects like Pytdbot

Buy me a Cup of TON

Compatibility

tdjson is compatible with the following platforms:

  • Linux (x64, ARM64) — 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)
if response:
    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

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.