{"id":46199300,"url":"https://github.com/nimaxin/init-data-py","last_synced_at":"2026-03-03T04:32:48.979Z","repository":{"id":252618609,"uuid":"840977062","full_name":"nimaxin/init-data-py","owner":"nimaxin","description":"A Python library that provides tools for using and validating Telegram mini app init data.","archived":false,"fork":false,"pushed_at":"2025-11-13T13:58:23.000Z","size":71,"stargazers_count":38,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-13T15:31:05.565Z","etag":null,"topics":["python","telegram","telegram-mini-app","telegram-web-app"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nimaxin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-11T09:19:04.000Z","updated_at":"2025-11-13T13:57:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"708251ce-45a2-4f49-b891-8ef0ec939968","html_url":"https://github.com/nimaxin/init-data-py","commit_stats":null,"previous_names":["nimaxin/init-data-py"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/nimaxin/init-data-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimaxin%2Finit-data-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimaxin%2Finit-data-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimaxin%2Finit-data-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimaxin%2Finit-data-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nimaxin","download_url":"https://codeload.github.com/nimaxin/init-data-py/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimaxin%2Finit-data-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30032003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T03:27:35.548Z","status":"ssl_error","status_checked_at":"2026-03-03T03:27:09.213Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","telegram","telegram-mini-app","telegram-web-app"],"created_at":"2026-03-03T04:32:48.460Z","updated_at":"2026-03-03T04:32:48.975Z","avatar_url":"https://github.com/nimaxin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# init-data-py\n\n![Package version](https://img.shields.io/pypi/v/init-data-py?color=%2334D058\u0026label=pypi%20package)\n![License](https://img.shields.io/github/license/nimaxin/init-data-py)\n\nA Python library that provides tools for using and validating Telegram web app init data.\n\n## Installation\n\nYou can install the library using pip:\n\n```bash\npip install init-data-py\n```\n\n## Usage\n\n### Parsing\n\nTo parse the `window.Telegram.WebApp.initData` query string into an `InitData` object for easier access to attributes and validation, you can use the `InitData.parse` method:\n\n```python\nfrom init_data_py import InitData\n\ninit_data = InitData.parse(query_string)\n```\n\n### Validation\n\nTo validate the init data, you can use the `InitData.validate` method:\n\n```python\nis_valid = init_data.validate(bot_token)\n```\n\n### Signing\n\nIf you need to create and sign your own init data, you can create an `InitData` object and sign it:\n\n```python\nfrom init_data_py import InitData\nfrom init_data_py.types import User\n\nuser = User(id=5167898484, first_name=\"xin\")\ninit_data = InitData(user=user).sign(bot_token)\n```\n\n### Converting InitData to Query String\n\nAfter creating and signing init data, you can convert it to a query sting using the `InitData.to_query_string` method:\n\n```python\nquery_string = init_date.to_query_string()\n```\n\n### Real-World Validation Example\n\nThis example demonstrates how to validate a Telegram Mini App init data. It parses the init data query string into an `InitData` object and validate it using the provided bot token, checking that the data is valid and has not expired:\n\n```python\nfrom init_data_py import InitData\n\nbot_token = \"7244657541:AAEgqk0HDC3WD5cdbnGMdd6L0TJ74FDp97Y\"\nquery_string = \"query_id=AAF03wc0AgAAAHTfBzROOCVW\u0026user=%7B%22id%22%3A5167898484%2C%22first_name%22%3A%22xin%22%2C%22last_name%22%3A%22%22%2C%22username%22%3A%22pvnimaxin%22%2C%22language_code%22%3A%22en%22%2C%22allows_write_to_pm%22%3Atrue%7D\u0026auth_date=1722938610\u0026hash=8654c8c617c143abf656f4f159be2539880a56f58c2d9be622f90c0346aa162b\"\n\ninit_data = InitData.parse(query_string)\n\nis_valid = init_data.validate(\n    bot_token=bot_token,\n    lifetime=3600,\n)\n```\n\n## License\n\nThis library is licensed under the [MIT License](LICENCE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimaxin%2Finit-data-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnimaxin%2Finit-data-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimaxin%2Finit-data-py/lists"}