Skip to main content

Telegram Mini App Helpers

A Python package with helper functions for Telegram Mini Apps.

Features

  • Validates initData from Telegram Mini Apps.
  • Modern Python packaging using pyproject.toml
  • Type hints and static type checking with mypy
  • Code formatting and linting with Ruff
  • Comprehensive testing setup
  • GitHub Actions for CI/CD

Installation

pip install tma-functions

Usage

from tma_functions.auth import validate_auth_data

# Example usage for auth data validation
bot_token = "YOUR_BOT_TOKEN"
auth_data = "auth_date=1678886400\nhash=YOUR_HASH\nquery_id=YOUR_QUERY_ID\nuser={\"id\":123,\"first_name\":\"John\",\"last_name\":\"Doe\",\"username\":\"john_doe\",\"language_code\":\"en\",\"allows_write_to_pm\":true,\"photo_url\":\"https://example.com/photo.jpg\"}"

user_data = validate_auth_data(bot_token, auth_data)
if user_data is not None:
    print(f"User ID: {user_data['id']}")
    print(f"Username: {user_data['username']}")
    print(f"Full name: {user_data['first_name']} {user_data['last_name']}")
    print(f"Language: {user_data['language_code']}")
else:
    print("Invalid auth data")

Development

This project uses modern Python development tools:

  • Hatch for project management
  • Ruff for linting and formatting
  • mypy for static type checking
  • pytest for testing

Setup Development Environment

  1. Install development dependencies:
pip install -e ".[dev]"
  1. Run tests:
pytest
  1. Run type checking:
mypy .
  1. Run linting:
ruff check .

Deploy

rm -rf ./dist
hatch build
twine upload ./dist/*

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for tma-functions 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tma-functions 0.1.2
File Size Uploaded
tma_functions-0.1.2.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tma-functions 0.1.2
File Interpreter ABI Platform
tma_functions-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / tma_functions-0.1.2.tar.gz

Download URL tma_functions-0.1.2.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
81383555bb061e17112e5223ea9b2335f729a9f37d1d53e17339e354c22c2aa7
BLAKE2b-256 checksum
How to use checksums
71010531ef51a6ebd55cbca3ba5fa42b5d1b8f6219aafa2c4650ebdb355c3921
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Release files / tma_functions-0.1.2-py3-none-any.whl

Download URL tma_functions-0.1.2-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce9d1471f32d49772c51bf2d472421c7d6fd1da874069ad78ff5ce90c2acb940
BLAKE2b-256 checksum
How to use checksums
7bf14dd84bf228692f233c3f39d9bcfa0e717337a24de3edded55d6b75fa05e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page