Python SDK for Fragment API - Buy Telegram Stars and Premium with dual commission modes (KYC/Non-KYC)
Project description
Fragment Stars API
Python SDK for purchasing Telegram Stars and Premium via Fragment API with dual commission modes.
Features
- 🔐 Dual Commission Modes: KYC (lower commission) and Non-KYC (higher commission)
- 💰 Prepayment Flow: Automatic prepayment handling for Non-KYC mode
- ⚡ Queue Management: Automatic polling and status tracking
- 🎁 Premium Eligibility: Check if users can receive Premium gifts
- 📊 Real-time Rates: Get current commission rates
- 🔄 Queue Status: Monitor queue length and pause state
Installation
pip install fragment-stars-api
Quick Start
Non-KYC Mode (Higher Commission)
No user cookies required - uses owner's cookies:
from fragment_api import FragmentAPIClient
client = FragmentAPIClient()
# Buy 50 stars (Non-KYC mode)
result = client.buy_stars("username", 50, seed="your_seed_base64")
print(f"Success: {result.success}")
print(f"Mode: {result.mode}") # 'no_kyc'
print(f"Commission: {result.commission_rate * 100}%")
KYC Mode (Lower Commission)
Requires user's Fragment cookies:
# Buy 50 stars (KYC mode)
result = client.buy_stars(
"username",
50,
seed="your_seed_base64",
cookies="user_cookies_base64" # Providing cookies = KYC mode
)
print(f"Mode: {result.mode}") # 'kyc'
Check Commission Rates
rates = client.get_rates()
print(f"Non-KYC: {rates.rate_no_kyc}%")
print(f"KYC: {rates.rate_with_kyc}%")
Check Premium Eligibility
result = client.check_premium_eligibility("username")
if result.eligible:
print("✅ User is eligible for Premium gift")
else:
print(f"❌ Not eligible: {result.error_code}")
Check Queue Status
status = client.get_queue_status()
print(f"Queue length: {status.queue_length}")
print(f"Is paused: {status.is_paused}")
API Reference
FragmentAPIClient(base_url, timeout, poll_timeout)
| Parameter | Type | Default | Description |
|---|---|---|---|
base_url |
str | https://fragment-api.ydns.eu:8443 |
API URL |
timeout |
float | 30.0 | Request timeout (seconds) |
poll_timeout |
float | 300.0 | Max wait for queue (seconds) |
buy_stars(username, amount, seed, cookies=None, wait=True)
Buy Telegram Stars.
| Parameter | Type | Required | Description |
|---|---|---|---|
username |
str | Yes | Telegram username |
amount |
int | Yes | Number of stars (minimum 50) |
seed |
str | Yes | Wallet seed (base64) |
cookies |
str | No | Fragment cookies (base64) - omit for Non-KYC mode |
wait |
bool | No | Wait for result (default: True) |
Returns: PurchaseResult with success, mode, commission_rate, etc.
buy_premium(username, duration, seed, cookies=None, wait=True)
Buy Telegram Premium.
| Parameter | Type | Required | Description |
|---|---|---|---|
username |
str | Yes | Telegram username |
duration |
int | Yes | Months (3, 6, or 12) |
seed |
str | Yes | Wallet seed (base64) |
cookies |
str | No | Fragment cookies (base64) - omit for Non-KYC mode |
wait |
bool | No | Wait for result (default: True) |
get_rates()
Get current commission rates.
Returns: CommissionRatesResponse with:
rate_no_kyc- Non-KYC rate (percentage)rate_with_kyc- KYC rate (percentage)rate_no_kyc_decimal- Non-KYC rate (decimal)rate_with_kyc_decimal- KYC rate (decimal)
check_premium_eligibility(username)
Check if user is eligible to receive Premium gift.
Returns: CheckEligibilityResponse with:
eligible- Whether user is eligibleerror_code- Error code if not eligibleerror_message- Error description
get_queue_status()
Get overall queue status.
Returns: QueueStatusInfo with:
queue_length- Number of requests in queueis_paused- Whether queue is pausedpause_reason- Reason for pause (if paused)
get_status(request_id)
Get specific request status.
Returns: QueuedRequest with status details.
Examples
See the examples directory for more:
buy_stars_no_kyc.py- Purchase with Non-KYC modebuy_stars_kyc.py- Purchase with KYC modecheck_eligibility.py- Check Premium eligibilitycheck_queue_status.py- Monitor queue status
Exceptions
from fragment_api import FragmentAPIError, QueueTimeoutError
try:
result = client.buy_stars("username", 50, seed="...")
except QueueTimeoutError:
print("Request timed out")
except FragmentAPIError as e:
print(f"Error: {e.error_code} - {e.message}")
License
MIT
Project details
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_stars_api-2.0.0.tar.gz.
File metadata
- Download URL: fragment_stars_api-2.0.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2be79402eb143269801e7e936fac98d6bc6c048ca4c8f7aadfe5954e040572fd
|
|
| MD5 |
263329978db2531962f70acc3c6358bf
|
|
| BLAKE2b-256 |
ef0c3c9a95bf751525649b8d5d19b1490c5abffdb8ae134c4f9873eba20d2481
|
File details
Details for the file fragment_stars_api-2.0.0-py3-none-any.whl.
File metadata
- Download URL: fragment_stars_api-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43741869bc3f4e8813aac61710011dc7a1c6013bc51e9767a02da32fc28a74ba
|
|
| MD5 |
ec7bb5c2578b7bfc2b17aae8946f98d2
|
|
| BLAKE2b-256 |
a5787e7e57f5065749e91b92d38e3c555b2565b7c76b7192ae16360beb114d5f
|