Skip to main content

Fragment API Python

Fragment API Python SDK

Professional Python library for Fragment.com automation
v9.0.0 — Batch Operations | EVM Payments | Tonconsole Integration

PyPI Python Versions Downloads Telegram License

GitHub Docs


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-onlyFragmentClient with full async/await support.
  • Reliable Networking — Requires a direct Tonconsole api_key for maximum uptime.
  • Purchases — Stars (50–10M), Premium (3/6/12 months), TON Ads.
  • Giveaways — Stars and Premium for channels (up to 24k winners).
  • Bidsplace_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:

Donate TON

UQBsyxZvyQxDwAeOxoaWwO2HJoAmCKUoJlS_OpLzWHD9i2Xj

License
MIT License — free for commercial and personal use.


GitHubDocumentationTelegram

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fragment_api_py-9.0.0.tar.gz (52.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fragment_api_py-9.0.0-py3-none-any.whl (68.8 kB view details)

Uploaded Python 3

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

Hashes for fragment_api_py-9.0.0.tar.gz
Algorithm Hash digest
SHA256 db6e4a714ecd6c0cf1b663703e440507bbeeb38eb5ad1dee102fcded68083702
MD5 8068ef93469dd97c2836722b1494780f
BLAKE2b-256 ce2a9636ee2e763a409c696ee727c955415d31f7ee0b438d4c36d20c06ea286a

See more details on using hashes here.

File details

Details for the file fragment_api_py-9.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fragment_api_py-9.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9013e51ad2608a3d46169b09bc2348f1d949a20dd03c5fe482071553a8d75371
MD5 07890a2db7c2acae8d9f09125b54e8a9
BLAKE2b-256 025d0bcfc69667df01335690ec7f309f7023547b8c3d6ccae808edc2240b68a9

See more details on using hashes here.

Release history Release notifications | RSS feed

12.1.0

2 files

12.0.0

2 files

11.0.0

2 files

10.0.0

2 files

9.0.2

2 files

9.0.1

2 files

This release

9.0.0 This release

2 files

8.1.0

2 files

8.0.0

2 files

7.0.0

2 files

6.1.0

2 files

6.0.1

2 files

5.0.1

2 files

4.0.0

2 files

3.2.0

2 files

3.1.0

2 files

3.0.3

2 files

3.0.2

2 files

3.0.1

2 files

2.0.3

2 files

2.0.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page