1.0.0 • Published 11 months ago
@teledeveloperz/twa-sdk v1.0.0
Telegram Web Apps (TWA) SDK
An enhanced TypeScript SDK for Telegram Web Apps (TWA), providing easy access to user data and Telegram Bot API functionality.
Features
- TypeScript support for better developer experience
- Easy access to TWA user data
- Integration with Telegram Bot API
- Utility functions for common TWA operations
Installation
npm install @teledeveloperz/twa-sdk
Usage
import { TWASDK } from "@teledeveloperz/twa-sdk";
// Initialize the SDK with the TWA init data
const sdk = new TWASDK(window.Telegram.WebApp.initData);
// Access user information
console.log(sdk.user.getFullName());
// Make API calls
sdk.getBotInfo().then(botInfo => {
console.log("Bot info:", botInfo);
});
API Reference
TWASDK
The main class for interacting with the TWA SDK.
Constructor
new TWASDK(initData: string)
initData
: The initialization data provided by Telegram Web App.
Properties
user
: An instance ofTelegramUser
containing user information.
Methods
getBotInfo()
: Fetches information about the bot.getUserProfilePhotos(userId: number)
: Fetches profile photos for a given user ID.
TelegramUser
A class representing the Telegram user.
Methods
getId()
: Returns the users
1.0.0
11 months ago