A Python library that offers simple interface for validating Telegram Mini App initialization data.
Project description
init-data-python
A Python library that offers simple interface for validating Telegram Mini App initialization data.
Installation
pip install init-data-python
Usage
Instantiate InitData with raw initialization data and a bot token, then call .validate() to get the validation
result as a boolean.
from init_data import InitData
init_data_raw = "query_id=AAHdF6IQAAAAAN0XohDhrOrc&user=%7B%22id%22%3A279058397%2C%22first_name%22%3A%22Vladislav%22%2C%22last_name%22%3A%22Kibenko%22%2C%22username%22%3A%22vdkfrost%22%2C%22language_code%22%3A%22ru%22%2C%22is_premium%22%3Atrue%7D&auth_date=1662771648&hash=c501b71e775f74ce10e377dea85a7ea24ecd640b223ea86dfe453e0eaed2e2b2"
bot_token = "5768337691:AAH5YkoiEuPk8-FZa32hStHTqXiLPtAEhx8"
InitData(init_data_raw, bot_token).validate() # -> True
You can also specify the number of decoding iterations if the initialization data was encoded multiple times.
InitData(...).validate(times_to_decode=2)
- Note:
times_to_decodeis a keyword-only parameter.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file init_data_python-1.0.1.tar.gz.
File metadata
- Download URL: init_data_python-1.0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a6fba64a2e8fd99d121d9ea902324e974b6df05e6b29303a6fb109bf5b48341
|
|
| MD5 |
430e53b1728c9b5e50bc0d4800c2637b
|
|
| BLAKE2b-256 |
868f998b7c87cba6c76e27248e8a03bcda577d59baff765d06acc914733cc1f7
|
File details
Details for the file init_data_python-1.0.1-py3-none-any.whl.
File metadata
- Download URL: init_data_python-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2fa479de2cff6a638ba89c18bcf0842a9564277369a46459d970d7c1a4ce670
|
|
| MD5 |
c002dcac3972bcf0b11d626466c8d23c
|
|
| BLAKE2b-256 |
e03e42c351a456a155cf1a12239cac63129053fa784f504422bfd866e7f55cbb
|