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.1.tar.gz (53.0 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.1-py3-none-any.whl (69.2 kB view details)

Uploaded Python 3

File details

Details for the file fragment_api_py-9.0.1.tar.gz.

File metadata

  • Download URL: fragment_api_py-9.0.1.tar.gz
  • Upload date:
  • Size: 53.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.34.2

File hashes

Hashes for fragment_api_py-9.0.1.tar.gz
Algorithm Hash digest
SHA256 5dab9ca31467f55a028331d7a77fefa44baf02d9664a5f977ca949ca5b236840
MD5 02f570618069f90f3b5af1eed0a5bbad
BLAKE2b-256 f1df48f562d5bdd0d5e2e8ba8d5e776712f73025243241039be06a6b20c83fda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fragment_api_py-9.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f44c1ceeba78521b40144fb7ee57ecd0b62500fc12422b332a8d2cab15e0590c
MD5 fde4b06fd90919d235bd261a4f0b7079
BLAKE2b-256 7d3e74d868da58fd50eaa853231617a05016fc836e4a04a0c246f77e5dc1c6e8

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

This release

9.0.1 This release

2 files

9.0.0

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