Skip to main content

Fragment API Python

Fragment API Python SDK

Async Python library for Fragment.com automation
v10.0.0 — GRAM Rebrand | Batch Operations | EVM Payments | Full Marketplace

PyPI Python Versions Downloads Telegram License

GitHub Docs


What's New in v10.0.0

Feature Description
GRAM Rebrand All TON references updated to GRAM following the Telegram Open Network rebrand. ton payment method and balance_ton properties remain as backward-compatible aliases.
Three Operating Modes Full mode (cookies + seed + api_key), EVM-only mode (cookies without stel_ton_token), Read-only mode (cookies only).
NFT Management Transfer gifts between users, withdraw NFTs to wallet, manage Stars revenue withdrawals.
Auction & Selling Start auctions, sell assets at fixed prices, place bids on usernames, numbers, and gifts.
Asset Assignment Assign owned usernames and gifts to specific Telegram accounts.

Features

  • Async-first — Full async/await support with FragmentClient.
  • Purchases — Stars (50–10M), Premium (3/6/12 months), GRAM Ads top-up.
  • Batch Operations — Multiple purchases in grouped on-chain transactions.
  • EVM Payments — USDT/USDC on Ethereum, Polygon, and BASE chains.
  • Giveaways — Stars and Premium giveaways for channels (up to 24K winners).
  • Marketplace — Search/bid on usernames, numbers, and gifts with full pagination.
  • Auctions — Start auctions, set fixed prices, place bids, buy-now.
  • NFTs — Transfer, withdraw to wallet, manage Stars revenue.
  • Wallet — V4R2 and V5R1 support via tonutils. GRAM and USDT balances.
  • Authentication — Auto-authenticate via TON wallet proof + Telegram OAuth (QR/phone).
  • Anonymous Numbers — Login codes, toggle delivery, terminate sessions (+888).
  • Asset Management — List owned assets, bid history, assign to Telegram accounts.

Installation

pip install fragment-api-py

Requirements:

  • Python 3.10+
  • Fragment cookies (stel_ssid, stel_dt, stel_token; stel_ton_token for wallet operations)
  • TON wallet seed phrase (12/18/24 words) — for on-chain transactions
  • Tonconsole or Toncenter API key — for blockchain interactions

Get a free API key at tonconsole.com.


Quick Start

import asyncio
from FragmentAPI import FragmentClient
from FragmentAPI.types.results import EvmPaymentResult

async def main():
    async with FragmentClient(
        cookies={
            "stel_ssid": "...",
            "stel_token": "...",
            "stel_dt": "...",
            "stel_ton_token": "..."
        },
        seed="word1 word2 ... word24",
        api_key="AF...",
        wallet_version="V5R1",
    ) as client:
        
        # Wallet info
        wallet = await client.get_wallet()
        print(f"Balance: {wallet.gram_balance} GRAM, {wallet.usdt_balance} USDT")
        
        # Purchase Stars
        result = await client.purchase_stars("durov", 100)
        print(f"TX: {result.transaction_id}")
        
        # Batch operations
        batch = await client.batch_purchase([
            {"type": "premium", "username": "durov", "months": 3},
            {"type": "stars", "username": "telegram", "amount": 250},
        ])
        print(f"Batch: {batch.succeeded}/{batch.total} succeeded")

        # EVM payment
        evm = await client.purchase_stars("durov", 50, payment_method="usdc_base")
        if isinstance(evm, EvmPaymentResult):
            inv = evm.invoice
            print(f"Send {inv.invoice_amount} {inv.token_symbol} to {inv.invoice_address}")

asyncio.run(main())

Authentication

import asyncio
from FragmentAPI import FragmentClient

async def main():
    # Auto-authenticate via TON wallet + Telegram
    cookies = await FragmentClient.authenticate(
        seed="word1 word2 ... word24",
        wallet_version="V5R1",
        phone="+71234567890",  # Omit for QR code flow
    )
    
    async with FragmentClient(
        cookies=cookies,
        seed="word1 word2 ... word24",
        api_key="AF...",
    ) as client:
        profile = await client.get_profile()
        print(f"Logged in as: {profile.name}")

asyncio.run(main())

Payment Methods

Method Chain Token Behavior
gram / ton TON (Gram) GRAM Automatic on-chain TX
usdt_gram / usdt_ton TON (Gram) USDT Automatic on-chain 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

API Overview

For complete method signatures, parameters, return types, and models, see the Full Documentation (DOC.md).

Purchases & Giveaways

Method Description
purchase() Unified single/batch purchase
purchase_stars() Send Stars to a user
purchase_premium() Gift Premium to a user
topup_gram() Top up GRAM to Ads balance
batch_purchase() Batched multi-item purchases
giveaway_stars() Stars giveaway for a channel
giveaway_premium() Premium giveaway for a channel

Marketplace

Method Description
search_usernames() Search username listings
search_numbers() Search anonymous numbers
search_gifts() Search gift marketplace
place_bid() Bid or buy-now on an item
start_auction() Start an auction
sell_asset() Sell at a fixed price

Asset Info & History

Method Description
get_username_info() Detailed username info
get_number_info() Detailed number info
get_gift_info() Detailed gift info
get_stars_prices() Stars package prices
get_premium_prices() Premium prices
get_stars_history() Stars transaction history
get_premium_history() Premium transaction history
get_topup_history() Ads topup history

Account & Assets

Method Description
get_wallet() Wallet address & balances
get_profile() Account profile info
get_sessions() Active sessions
get_my_assets() Owned assets
get_my_bids() Bid history
assign_to_telegram() Assign asset to account

NFTs & Withdrawals

Method Description
transfer_nft() Transfer gift to user
init_nft_withdrawal() Withdraw NFT to wallet
init_stars_withdrawal() Withdraw Stars revenue

Anonymous Numbers

Method Description
get_login_code() Fetch pending login code
toggle_login_codes() Enable/disable code delivery
terminate_sessions() Terminate all sessions

Support & License

Issues: GitHub Issues or Telegram Chat

Support the Project:

Donate GRAM

UQBsyxZvyQxDwAeOxoaWwO2HJoAmCKUoJlS_OpLzWHD9i2Xj

License: MIT — 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-10.0.0.tar.gz (50.7 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-10.0.0-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fragment_api_py-10.0.0.tar.gz
Algorithm Hash digest
SHA256 e5e924149ae823dcd293790570de672528daeac657e664abeb1b22aa4d03f012
MD5 91a8ad2fef2dabe8c60d769359a29637
BLAKE2b-256 fb2d5577e2b859013bfdd5bb242c9a26060fb720c4457907dc9720f6c68f2127

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fragment_api_py-10.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0d9c5c460e1f65e231087e527d4da2757aff2ce76d268b23c336bfda184cd71
MD5 533e4d1cbe394a9f69e11f24714ccdb2
BLAKE2b-256 91b78a695282d97deda84fdec0b7f6caf08b8a7244d1a96a3d49c661451b93a8

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

This release

10.0.0 This release

2 files

9.0.2

2 files

9.0.1

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