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

python
from fragment_api import FragmentAPIClient
client = 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.

python
from fragment_api import FragmentAPIClient
client = 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.

python
from fragment_api import FragmentAPIClient
client = 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.

python
from fragment_api import FragmentAPIClient
client = 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

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!