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. Normal client endpoints do not need an API key. Replace YOUR_BASE64_ENCODED_SEED and YOUR_BASE64_ENCODED_COOKIES on your backend only. Never commit these values or expose them in frontend code.
Buy Telegram Stars
Purchase Stars through the Python SDK. No API key is required.
from fragment_api import FragmentAPIClientclient = FragmentAPIClient("https://fragment-api.ydns.eu:8443")result = client.buy_stars(username="@username",amount=100,seed="BASE64_WALLET_SEED",# Optional: "ton" (default) or "usdt_ton"payment_method="ton",)if result.success:print(f"Stars sent: {result.amount}")print(f"Transaction: {result.transaction_hash}")else:print(f"Error: {result.error}")
Buy Telegram Stars with USDT on TON
Use USDT on TON for the Stars base price; existing clients can omit payment_method and keep TON.
from fragment_api import FragmentAPIClientclient = FragmentAPIClient("https://fragment-api.ydns.eu:8443")result = client.buy_stars(username="@username",amount=100,seed="BASE64_WALLET_SEED",payment_method="usdt_ton",)print(result.success)print(result.cost_usdt_ton)print(result.payment_method)
Buy Telegram Premium in KYC Mode
KYC mode is permanently free with 0% API commission when Fragment cookies are provided.
from fragment_api import FragmentAPIClientclient = FragmentAPIClient("https://fragment-api.ydns.eu:8443")result = client.buy_premium(username="@username",duration=3,seed="BASE64_WALLET_SEED",cookies="BASE64_FRAGMENT_COOKIES",payment_method="ton",)print(result.success)print(result.transaction_hash)
Get Prices and Rates
Show TON and USDT-on-TON prices before checkout.
from fragment_api import FragmentAPIClientclient = FragmentAPIClient("https://fragment-api.ydns.eu:8443")prices = client.get_prices()rates = client.get_rates()print(prices)print(f"KYC rate: {rates.rate_with_kyc}%")
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!