Документация 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:

Install via pipbash
pip install fragment-stars-api
View on PyPI
Version:1.1.0

📘TypeScript SDK

The TypeScript SDK is available in the repository. Install it locally:

Install from sourcebash
# 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.

Source Code

Both Python and TypeScript SDKs are open source and available on GitHub:

View on 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

python
from fragment_stars_api import FragmentStarsAPI
# Initialize the API client
api = FragmentStarsAPI(
api_key="YOUR_API_KEY",
base_url="https://fragment-api.ydns.eu:8443"
)
# Create an order to buy 100 Stars
order = 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 order
payment = api.pay_order(order['order_id'])
print(f"Payment status: {payment['status']}")
# Check order status
status = api.get_order_status(order['order_id'])
print(f"Order status: {status['status']}")

Buy Telegram Premium

Purchase Telegram Premium subscription for a user

python
from fragment_stars_api import FragmentStarsAPI
# Initialize the API client
api = FragmentStarsAPI(
api_key="YOUR_API_KEY",
base_url="https://fragment-api.ydns.eu:8443"
)
# Create an order for 3 months of Premium
order = api.create_premium_order(
telegram_user_id=123456789,
months=3, # 3, 6, or 12 months
seed="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 order
payment = api.pay_order(order['order_id'])
print(f"Payment status: {payment['status']}")

Check Wallet Balance

Check the TON balance of your wallet

python
from fragment_stars_api import FragmentStarsAPI
# Initialize the API client
api = FragmentStarsAPI(
api_key="YOUR_API_KEY",
base_url="https://fragment-api.ydns.eu:8443"
)
# Get wallet balance
balance = 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 order
min_balance = 10.0 # TON
if float(balance['balance_ton']) >= min_balance:
print("✓ Sufficient balance")
else:
print(f"✗ Insufficient balance. Need at least {min_balance} TON")

Additional Resources

Возможности SDK

Типобезопасность

Полная поддержка TypeScript с комплексными определениями типов для всех эндпоинтов API и ответов

Простота использования

Простой, интуитивный API с разумными значениями по умолчанию и комплексной обработкой ошибок

Безопасность

Встроенные лучшие практики безопасности с принудительным HTTPS и управлением учетными данными

Хорошо документирован

Комплексная документация с примерами, руководствами и справочником API

Справочник API

Основные методы

  • createStarsOrder()- Create an order to buy Telegram Stars
  • createPremiumOrder()- Create an order to buy Telegram Premium
  • payOrder()- Pay for a created order
  • getOrderStatus()- Check the status of an order
  • getWalletBalance()- Check wallet balance
  • getPrices()- Get current prices for Stars and Premium
  • getCommissionRates()- Verify current KYC and non-KYC commission rates before use

💡 Совет: Для подробной документации API, включая все параметры, типы ответов и коды ошибок, посетите страницу Документации API.

Поддержка и участие

Нужна помощь или хотите внести вклад? Мы приветствуем issues, pull requests и обратную связь!