Back to Trending
Repository
ganiry

ganiry/Telegram-Web-API-Cheatsheet

A simple cheatsheet for telegram mini apps

156stars
10forks
0issues
0views

📋 Telegram Web API Cheatsheet — tài liệu gọn cho Mini Apps

Một trang cheatsheet đơn giản, tập trung vào những API thực sự dùng hàng ngày khi xây dựng Telegram Mini Apps — không rườm rà, có code mẫu copy-paste chạy ngay.

Dự án của ganiry gom lại các đoạn code khởi tạo, theme CSS, xác thực người dùng (initData), thao tác Back Button/Main Button, xác nhận đóng, mở link và hiển thị popup — tất cả đều lấy từ tài liệu chính thức Telegram Bot API nhưng trình bày dạng "tra cứu nhanh". Phù hợp cho dev đang nhúng web app vào Telegram và cần nhớ cú pháp mà không muốn lướt qua trang docs dài dòng.

✨ Điểm nổi bật

  • CSS Theme Variables: Danh sách biến --tg-theme-* (bg-color, text-color, hint-color, link-color, button-color, button-text-color, secondary-bg-color) và cách truy xuất qua Telegram.WebApp.themeParams để UI tự đồng bộ theme Telegram của người dùng.
  • Xác thực initData (HMAC-SHA256): Hướng dẫn đầy đủ quy trình: lấy Telegram.WebApp.initData → tách hash → sort params → tạo data-check-string → ký HMAC với secret key HMAC_SHA256(bot_token, "WebAppData") → so khớp hash. Kèm hàm verifyTelegramWebAppData viết sẵn bằng Node.js crypto.
  • Lấy dữ liệu user frontend: Parse initData qua URLSearchParams, JSON.parse(user) để có object userData sẵn dùng.
  • Back Button: show(), hide(), onClick(), offClick(), isVisible — điều khiển nút quay lại góc trái.
  • Main Button: Toàn bộ property (text, color, textColor, isVisible, isActive, isProgressVisible) và method (setText, show, hide, enable, disable, showProgress, hideProgress).
  • Closing Confirmation: enableClosingConfirmation() / disableClosingConfirmation() — hỏi xác nhận trước khi user đóng Mini App.
  • Open Link & Popup: openLink(url) mở trong browser, showPopup({title, message, buttons}) hiển thị dialog native.

💡 Vì sao đáng chú ý

Cheatsheet này cắt bỏ phần lý thuyết, chỉ giữ lại cú pháp và luồng thực tế — chính thứ dev cần khi ngồi code. Phần xác thực initData là điểm giá trị nhất: nhiều tutorial chỉ nói "validate hash" mà không cho code hoàn chỉnh, ở đây có hàm verifyTelegramWebAppData sẵn, giải thích rõ data-check-string, secret key, thứ tự sort params — copy vào backend là chạy. Các ví dụ Back/Main Button cũng viết theo pattern event listener (onClick/offClick) thay vì pseudo-code, dễ tích hợp vào React/Vue/Svelte.


#Telegram #MiniApps #WebApp #Cheatsheet #TiniX

Similar Projects

Discover other similar projects and AI models.

RepositoryJavaScript
LeCoupa/awesome-cheatsheets

👩‍💻👨‍💻 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file.

46.6k
Oct 17, 2026
RepositoryGo
cheat/cheat

cheat allows you to create and view interactive cheatsheets on the command-line. It was designed to help remind *nix system administrators of options for commands that they use frequently, but not frequently enough to remember.

13.5k
May 19, 2026
RepositoryHTML
github/training-kit

Open source courseware for Git and GitHub

5.1k
Sep 10, 2026
RepositoryTypeScript
tbxark/mail2telegram

Receive email in Telegram: instant push notifications plus a Mini App inbox.

904
Oct 22, 2026
RepositoryTypeScript
deptyped/vue-telegram

Telegram integration for Vue

281
Mar 3, 2026
RepositoryTypeScript
nikandr-surkov/Hamster-Kombat-Telegram-Mini-App-Clone

Free Hamster Kombat clone — learn to build a Telegram Mini App tap-to-earn game with Next.js & TypeScript. Full production-ready source code + video guide available.

273
Jun 29, 2026
RepositoryPython
swimmwatch/telegram-webapp-auth

:lock: Python package that implements Telegram Mini Apps authentication algorithms.

100
Oct 5, 2026
Repository
DavisDmitry/telegram-webapps

TypeScript typings for Telegram Mini Apps

95
Jun 1, 2026
RepositoryPHP
CrazyTapok-bit/tgWebValid

An easy way to validate Telegram Login Widget and Telegram Mini App users on your website using PHP

68
Mar 26, 2026