Fragment API Python
One async client. Explicit payment states. A complete Fragment workspace.
Stars · Premium · Gifts · Usernames · Numbers · Ads · Gateway
Read the documentation / Explore examples / Report an issue
Built for explicit workflows
fragment-api-py is an unofficial asynchronous Python SDK for Fragment.com.
Browse the marketplace, resolve recipients, prepare transactions for external signing, or configure a payer wallet for automatic broadcasting. Work with typed results instead of treating every accepted request as a completed purchase.
Release 13.0.0
A new authentication and transaction architecture.
| Area | What changed |
|---|---|
| Authentication | Restricted wallet-proof sessions replace the MarketApp integration |
| Transport | A reusable client-owned HTTP session with cached API hashes |
| Payments | Distinct unsigned preparation, broadcast, and fulfillment states |
| Wallets | V4R2, V5R1, HighloadV2, and HighloadV3R1 configuration |
| Batches | Ordered invoice processing with per-item outcomes |
| Storage | Atomic file replacement, collision-resistant filenames, and explicit Redis cleanup |
| Parsing | Table-fragment handling, decimal preservation, responsive statuses, and merged gift filters |
| Validation | Strict integer inputs, original giveaway package limits, and capability guards |
Choose your workflow
| Workflow | Configuration | Result |
|---|---|---|
| Account browsing | Your Fragment cookies | Marketplace and user-owned account data |
| Restricted session | No cookies; wallet authentication | Allowed public and purchase workflows |
| External TON signing | A complete sender account or an offline-derived payer account, without automatic payment credentials | PreparedTransaction |
| Automatic TON payment | Payer seed and blockchain API key | Broadcast receipt with explicit confirmation state |
| EVM payment | Supported EVM payment method | An invoice for external payment |
Account operations require a user-owned cookie session. Native automatic payments in cookie mode additionally require a wallet-connected session.
Restricted wallet authentication does not bypass Fragment verification requirements. The shared authentication wallet is separate from the configured payer.
Installation
Python 3.10 or newer
Install from PyPI with pip install fragment-api-py.
Optional integrations:
| Extra | Installation |
|---|---|
| Redis storage | pip install "fragment-api-py[redis]" |
| Terminal QR rendering | pip install "fragment-api-py[qr]" |
| Development tools | pip install "fragment-api-py[dev]" |
Automatic TON payments require a valid mnemonic and a provider key from Tonconsole or Toncenter.
Start with an example
The repository keeps executable examples in one place rather than duplicating code throughout the documentation.
| Your goal | Start here |
|---|---|
| Configure the client | Basic setup |
| Authenticate a full account | Authentication |
| Understand restricted mode | Wallet authentication |
| Buy Stars or Premium | Stars · Premium |
| Prepare an external payment | External signing |
| Search gifts and attributes | Marketplace search |
| Handle payment outcomes | Error handling |
Browse the complete example guide
Payment networks
| Method | Network | Asset | SDK behavior |
|---|---|---|---|
ton, gram |
TON | TON | Prepare or broadcast |
usdt_ton, usdt_gram |
TON | USDT | Prepare or broadcast |
usdt_eth |
Ethereum | USDT | External invoice |
usdt_pol |
Polygon | USDT | External invoice |
usdc_eth |
Ethereum | USDC | External invoice |
usdc_base |
Base | USDC | External invoice |
usdc_pol |
Polygon | USDC | External invoice |
Availability is subject to Fragment's response and operation-specific restrictions. Ads and Gateway recharge flows use native TON.
Know what happened
| State | Meaning |
|---|---|
| Prepared | An unsigned transaction exists; nothing has been broadcast |
| Broadcast | The wallet call returned; fulfillment has not necessarily completed |
| Confirmed | The purchase flow observed Fragment's completion signal |
| Unknown | The broadcast outcome could not be established; reconciliation is required |
Documentation
|
Integration Client and authentication |
Marketplace and operations Marketplace and search |
Operational notes
- Reuse a client and close it with an asynchronous context manager or
aclose(). - Keep payer credentials, session cookies, and login codes out of source control and logs.
- Use your own sender account for external signing.
- Never deposit funds into the shared authentication wallet.
- Coordinate access when multiple clients or processes use the same payer.
- Fragment HTML and private endpoints can change independently of this package.
- This project is not affiliated with or endorsed by Fragment, Telegram, or TON.
Support the project
Development, maintenance, and issue reports are welcome.
TON address
UQAcsdD09x9dzj7Jc-MznN-SLUxPPMmwKQxsC2Ax_F03TBAH
Metadata
Release files for fragment-api-py 13.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fragment_api_py-13.0.0.tar.gz | 57.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fragment_api_py-13.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 126.4 kB
Release files / fragment_api_py-13.0.0.tar.gz
| Download URL | fragment_api_py-13.0.0.tar.gz |
|---|---|
| Size | 57.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ad95a31fa99d395d8a8546f82b0fa01fa516b9dee297d5b63873a2e748e2187
|
|
BLAKE2b-256 checksum How to use checksums |
4f4fa83666a7c2e6dbf0ed01e7d6ee99b2de024ec5c263666748b82bddc5ce02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.34.2
|
Release files / fragment_api_py-13.0.0-py3-none-any.whl
| Download URL | fragment_api_py-13.0.0-py3-none-any.whl |
|---|---|
| Size | 68.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ccdeb7eac97cbd1f0d7ef4f46e4406710b017ec469c535f894cbeccfa77e0d4
|
|
BLAKE2b-256 checksum How to use checksums |
86eb0d130e4e16aee19cde816fb2c074a62cba89ad0a5558c207e9248cdec8e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.34.2
|