SDK Documentation
Official Python and TypeScript SDKs for Fragment Stars API. Install, configure, and start buying Telegram Stars and Premium subscriptions.
🚀Quick Start
Get started with Fragment Stars API in minutes. Choose your preferred language and follow the installation instructions below.
🐍Python Developers
Install via pip and start building with our comprehensive Python SDK
📘TypeScript Developers
Use our type-safe TypeScript SDK for Node.js and browser applications
Installation
🐍Python SDK
Install the official Python SDK from PyPI:
pip install fragment-stars-api
📘TypeScript SDK
The TypeScript SDK is available in the repository. Install it locally:
# Clone the repository git clone https://github.com/bbbuilt/fragment-stars-api.git cd fragment-stars-api # Install dependencies npm install # Build the SDK npm run build
Note: The TypeScript SDK is not yet published to npm. You can use it by installing from the local repository or GitHub.
Code Examples
Security Notice
The examples below use placeholder values for sensitive data. Replace YOUR_API_KEY, YOUR_BASE64_ENCODED_SEED, and YOUR_BASE64_ENCODED_COOKIES with your actual credentials. Never commit these values to version control!
Buy Telegram Stars
Purchase Telegram Stars for a user
from fragment_stars_api import FragmentStarsAPI# Initialize the API clientapi = FragmentStarsAPI(api_key="YOUR_API_KEY",base_url="https://fragment-api.ydns.eu:8443")# Create an order to buy 100 Starsorder = api.create_stars_order(telegram_user_id=123456789,stars_amount=100,seed="YOUR_BASE64_ENCODED_SEED",fragment_cookies="YOUR_BASE64_ENCODED_COOKIES",use_kyc=True # KYC mode has 0% API commission)print(f"Order created: {order['order_id']}")print(f"Status: {order['status']}")print(f"Total cost: {order['total_cost_ton']} TON")# Pay for the orderpayment = api.pay_order(order['order_id'])print(f"Payment status: {payment['status']}")# Check order statusstatus = api.get_order_status(order['order_id'])print(f"Order status: {status['status']}")
Buy Telegram Premium
Purchase Telegram Premium subscription for a user
from fragment_stars_api import FragmentStarsAPI# Initialize the API clientapi = FragmentStarsAPI(api_key="YOUR_API_KEY",base_url="https://fragment-api.ydns.eu:8443")# Create an order for 3 months of Premiumorder = api.create_premium_order(telegram_user_id=123456789,months=3, # 3, 6, or 12 monthsseed="YOUR_BASE64_ENCODED_SEED",fragment_cookies="YOUR_BASE64_ENCODED_COOKIES",use_kyc=False # Use non-KYC mode)print(f"Premium order created: {order['order_id']}")print(f"Duration: {order['months']} months")print(f"Total cost: {order['total_cost_ton']} TON")# Pay for the orderpayment = api.pay_order(order['order_id'])print(f"Payment status: {payment['status']}")
Check Wallet Balance
Check the TON balance of your wallet
from fragment_stars_api import FragmentStarsAPI# Initialize the API clientapi = FragmentStarsAPI(api_key="YOUR_API_KEY",base_url="https://fragment-api.ydns.eu:8443")# Get wallet balancebalance = api.get_wallet_balance(seed="YOUR_BASE64_ENCODED_SEED")print(f"Wallet address: {balance['address']}")print(f"Balance: {balance['balance_ton']} TON")print(f"Balance (nanoton): {balance['balance_nanoton']}")# Check if balance is sufficient for an ordermin_balance = 10.0 # TONif float(balance['balance_ton']) >= min_balance:print("✓ Sufficient balance")else:print(f"✗ Insufficient balance. Need at least {min_balance} TON")
Additional Resources
- →For complete API documentation, see the API Documentation page
- →Test public endpoints in the API Playground
- →View source code and contribute on GitHub
- →See a ready-made Telegram Stars and Premium shop example: tg_stars_premium_shop
SDK Features
Type Safety
Full TypeScript support with comprehensive type definitions for all API endpoints and responses
Easy to Use
Simple, intuitive API with sensible defaults and comprehensive error handling
Secure
Built-in security best practices with HTTPS enforcement and credential management
Well Documented
Comprehensive documentation with examples, guides, and API reference
API Reference
Core Methods
createStarsOrder()- Create an order to buy Telegram StarscreatePremiumOrder()- Create an order to buy Telegram PremiumpayOrder()- Pay for a created ordergetOrderStatus()- Check the status of an ordergetWalletBalance()- Check wallet balancegetPrices()- Get current prices for Stars and PremiumgetCommissionRates()- Verify current KYC and non-KYC commission rates before use
💡 Tip: For detailed API documentation including all parameters, response types, and error codes, visit the API Documentation page.
Support & Contributing
Need help or want to contribute? We welcome issues, pull requests, and feedback!