Skip to content
/ tdjson Public

High-performance Python binding for TDLib JSON interface

License

Notifications You must be signed in to change notification settings

AYMENJD/tdjson

Repository files navigation

tdjson Version TDLib version Downloads

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

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:

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))

# 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.

License

MIT LICENSE

About

High-performance Python binding for TDLib JSON interface

Topics

Resources

License

Stars

Watchers

Forks