fragment-api-dev
The focused Python SDK for buying Telegram Stars and Telegram Premium through Fragment.
- GRAM and USDT on TON
- No API key
- Automatic status polling
- Zero runtime dependencies
Install
pip install fragment-api-dev
Quick start
import os
from fragment_api import FragmentAPI
api = FragmentAPI()
purchase = api.buy_stars(
username="@telegram_user",
amount=50,
payment_method="gram",
seed=os.environ["TON_WALLET_SEED"],
)
result = api.wait(purchase.purchase_id)
if result.completed:
print("Delivered:", result.transaction_hash)
else:
print("Not completed:", result.status, result.error)
The SDK generates an idempotency key automatically, submits the purchase, and provides a typed Purchase result.
Prices
Get the 50-Stars reference price and Premium prices for 3, 6, and 12 months before showing a price to your customer:
catalog = api.get_prices()
print(catalog.stars.amount, catalog.stars.prices.gram, catalog.stars.prices.usdt)
quote = api.get_stars_price(100)
print(quote.prices.gram, quote.prices.usdt)
Use get_premium_price(3), get_premium_price(6), or get_premium_price(12) for Premium. Price values are strings to preserve their exact decimal value. A quote can have stale=True when the latest available quote is being served.
Telegram Premium
purchase = api.buy_premium(
username="@telegram_user",
months=3,
payment_method="usdt",
seed=os.environ["TON_WALLET_SEED"],
)
result = api.wait(purchase.purchase_id)
Premium durations are 3, 6, or 12 months.
Payments
| Value | Payment |
|---|---|
gram |
GRAM on TON |
usdt |
USDT on TON |
USDT purchases require a small GRAM balance for the network fee.
Public API
| Method | Purpose |
|---|---|
buy_stars() |
Buy 50 or more Telegram Stars |
buy_premium() |
Buy Telegram Premium |
create_purchase() |
Create a purchase with explicit product fields |
get_purchase() |
Read the latest purchase state |
get_prices() |
Read the 50-Stars reference and Premium price catalog |
get_price() |
Read a Stars or Premium quote |
get_stars_price() |
Read a Stars quote for 50 to 1,000,000 Stars |
get_premium_price() |
Read a quote for 3, 6, or 12 months of Premium |
wait() |
Poll until the purchase reaches a terminal state |
No authentication token or API key is required.
Links
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fragment_api_dev-1.1.0.tar.gz.
File metadata
- Download URL: fragment_api_dev-1.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d37892ca3080f969fd8585619fc6aa738f70d72e50f8c63394630b83fe4cb09
|
|
| MD5 |
55471206b38877d18a033177d1b65efe
|
|
| BLAKE2b-256 |
b87f138d199a8b9be5473513406c9a630308f5b3883d0b61fee344d2ad7d86be
|
File details
Details for the file fragment_api_dev-1.1.0-py3-none-any.whl.
File metadata
- Download URL: fragment_api_dev-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6d92e4e5fa70de7ef8689c228d83b3cf551916669618cd9b0e34bba378faf13
|
|
| MD5 |
defdb2f7e69e22239193ad363d3497e7
|
|
| BLAKE2b-256 |
55580fc938b6851a6afef70bd75abea7365507b47ff00e9c87bb7c4f00c6ca31
|