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:

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

💡 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!