Skip to main content

A Python library that provides tools for using and validating Telegram web app init data.

Project description

init-data-py

A Python library that provides tools for using and validating Telegram web app init data.

Installation

You can install the library using pip.

pip install init-data-py

Usage

Parsing.

from init_data_py import InitData

query_string = "query_id=AAF03wc0Ag..."

InitData.from_query_string(query_string)

Signing

from init_data_py import InitData
from init_data_py.types import User

BOT_TOKEN = "7244657541:AA..."

init_data = InitData(
    user=User(
        id=5167898484,
        first_name="xin",
        username="pvnimaxin",
    )
).sign(bot_token=BOT_TOKEN)

Validation

from init_data_py import InitData

BOT_TOKEN = "7244657541:AA..."

init_data = InitData(...)
is_valid = init_data.validate(bot_token=BOT_TOKEN, lifetime=3600)

License

This library is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

init_data_py-0.1.0.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

init_data_py-0.1.0-py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page