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)
Built Distribution
Close
Hashes for init_data_py-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbeb81a0a6dd61e150ad5f91b2f006dcc972f8719764525a8da29b76b7e249f |
|
MD5 | ae1ec71d2d4c9d8817967a526b8e82e6 |
|
BLAKE2b-256 | 29019b824f86a5b30d296aa26af072c7773fc49f57e9d0d179c7ed7ca40a2672 |