Fragment API Python SDK
Professional Python library for Fragment.com automation
v9.0.0 — Batch Operations | EVM Payments | Tonconsole Integration
| Feature | Description |
|---|---|
| Strict Initialization | api_key (Tonconsole) and cookies are now strictly required for all operations. Built-in proxies and No-KYC modes were removed to guarantee maximum reliability and security. |
| Batch Operations | Execute multiple sequential transactions efficiently in a single on-chain operation using the unified batch_purchase method. |
| EVM Payments | Native support for 5 EVM methods: usdt_eth, usdt_pol, usdc_eth, usdc_base, usdc_pol. |
- Async-only —
FragmentClientwith full async/await support. - Reliable Networking — Requires a direct Tonconsole
api_keyfor maximum uptime. - Purchases — Stars (50–10M), Premium (3/6/12 months), TON Ads.
- Giveaways — Stars and Premium for channels (up to 24k winners).
- Bids —
place_bid(item_type=1|3|5, slug, bid)— instant buy if bid = buy-now price. - Marketplace — Search usernames, numbers, gifts with filters and pagination.
- Wallet — V4R2 and V5R1 (W5) support via
tonutils. - Auto-authentication — Obtain cookies via TON wallet and Telegram.
- Anonymous numbers — Manage login codes, terminate sessions (+888).
- NFT Management — Withdraw gifts to wallet, transfer to users.
pip install fragment-api-py
- Python 3.10+
- TON wallet seed phrase (12/18/24 words)
- Fragment cookies (
stel_ssid,stel_dt,stel_token,stel_ton_token) - Tonconsole API Key (get one for free at tonconsole.com)
import asyncio
from FragmentAPI import FragmentClient
from FragmentAPI.types.results import EvmPaymentResult
async def main():
# Initialize with strictly required credentials
async with FragmentClient(
seed="24 words...",
api_key="AF...", # Your Tonconsole API key is strictly required
cookies={
"stel_ssid": "...",
"stel_token": "...",
"stel_dt": "...",
"stel_ton_token": "..."
},
wallet_version="V5R1",
) as client:
# 1. Wallet info
wallet = await client.get_wallet()
print(f"Balance: {wallet.balance_ton} TON, {wallet.balance_usdt} USDT")
# 2. Purchase stars
result = await client.purchase_stars("@durov", 100)
print(f"TX: {result.transaction_id}")
# 3. Execute batch operations
batch = await client.batch_purchase([
{"type": "premium", "username": "@durov", "months": 3},
{"type": "stars", "username": "@telegram", "amount": 250}
])
print(f"Batch Succeeded: {batch.succeeded}/{batch.total}")
# 4. EVM payment (returns invoice)
evm_result = await client.purchase_stars("@durov", 50, payment_method="usdc_base")
if isinstance(evm_result, EvmPaymentResult):
inv = evm_result.invoice
print(f"Send {inv.invoice_amount} {inv.token_symbol} to {inv.invoice_address}")
print(f"Chain: {inv.invoice_chain_name}")
asyncio.run(main())
import asyncio
from FragmentAPI import FragmentClient
async def main():
# Automatic authentication via TON wallet and Telegram
cookies = await FragmentClient.authenticate(
seed="24 words...",
wallet_version="V5R1",
phone="+71234567890" # Optional: omit for QR code flow
)
# Use obtained cookies alongside your Tonconsole API key
async with FragmentClient(
seed="24 words...",
api_key="AF...",
cookies=cookies
) as client:
profile = await client.get_profile()
print(f"Logged in as: {profile.name}")
asyncio.run(main())
| Method | Chain | Token | Flow |
|---|---|---|---|
ton |
TON | TON | Automatic TX |
usdt_ton |
TON | USDT | Automatic TX |
usdt_eth |
Ethereum | USDT | Returns invoice |
usdt_pol |
Polygon | USDT | Returns invoice |
usdc_eth |
Ethereum | USDC | Returns invoice |
usdc_base |
BASE | USDC | Returns invoice |
usdc_pol |
Polygon | USDC | Returns invoice |
Reporting Errors
Create an Issue or message in the Telegram chat.
Support the Project
If you find this library useful, consider supporting its development:
UQBsyxZvyQxDwAeOxoaWwO2HJoAmCKUoJlS_OpLzWHD9i2Xj
License
MIT License — free for commercial and personal use.
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_py-9.0.0.tar.gz.
File metadata
- Download URL: fragment_api_py-9.0.0.tar.gz
- Upload date:
- Size: 52.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
python-requests/2.34.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db6e4a714ecd6c0cf1b663703e440507bbeeb38eb5ad1dee102fcded68083702
|
|
| MD5 |
8068ef93469dd97c2836722b1494780f
|
|
| BLAKE2b-256 |
ce2a9636ee2e763a409c696ee727c955415d31f7ee0b438d4c36d20c06ea286a
|
File details
Details for the file fragment_api_py-9.0.0-py3-none-any.whl.
File metadata
- Download URL: fragment_api_py-9.0.0-py3-none-any.whl
- Upload date:
- Size: 68.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
python-requests/2.34.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9013e51ad2608a3d46169b09bc2348f1d949a20dd03c5fe482071553a8d75371
|
|
| MD5 |
07890a2db7c2acae8d9f09125b54e8a9
|
|
| BLAKE2b-256 |
025d0bcfc69667df01335690ec7f309f7023547b8c3d6ccae808edc2240b68a9
|