Документация 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. 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
Типобезопасность
Полная поддержка 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 и обратную связь!