Документация SDK
Официальные Python и TypeScript SDK для Fragment Stars API. Установите, настройте и начните покупать Telegram Stars и Premium подписки.
🚀Быстрый старт
Начните работу с Fragment Stars API за несколько минут. Выберите предпочитаемый язык и следуйте инструкциям по установке ниже.
🐍Разработчики Python
Установите через pip и начните разработку с нашим комплексным Python SDK
📘Разработчики TypeScript
Используйте наш типобезопасный TypeScript SDK для Node.js и браузерных приложений
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
Типобезопасность
Полная поддержка TypeScript с комплексными определениями типов для всех эндпоинтов API и ответов
Простота использования
Простой, интуитивный API с разумными значениями по умолчанию и комплексной обработкой ошибок
Безопасность
Встроенные лучшие практики безопасности с принудительным HTTPS и управлением учетными данными
Хорошо документирован
Комплексная документация с примерами, руководствами и справочником API
Справочник API
Основные методы
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
💡 Совет: Для подробной документации API, включая все параметры, типы ответов и коды ошибок, посетите страницу Документации API.
Поддержка и участие
Нужна помощь или хотите внести вклад? Мы приветствуем issues, pull requests и обратную связь!