fragment-api.io docs
Get API key API key
LLMs.txt OpenAPI Swagger

The #1 Fragment API Provider

Telegram Stars API Provider · Documentation

REST API for buying Telegram Stars and Premium via Fragment. Pay from your merchant balance in TON or USDT TON. REST API для покупки Telegram Stars и Premium через Fragment. Оплата с баланса мерчанта в TON или USDT TON.

Base URLhttps://api.fragment-api.io
AuthX-API-Key: <key>
Swagger/docs

AuthenticationАвторизация

Every protected request requires a merchant API key in the request headers.Каждый защищённый запрос требует API-ключ мерчанта в заголовках.

Primary — header X-API-Key

X-API-Key: YOUR_API_KEY

Legacy — Bearer token

Authorization: Bearer YOUR_API_KEY

How to get a keyКак получить ключ

  1. Open @fapiproviderbotОткройте @fapiproviderbot
  2. Send /startОтправьте /start
  3. Tap API key — you'll see the prefix (abc12345...)Нажмите API key — показывается prefix (abc12345...)
  4. Full key is shown once at registration or rotationПолный ключ показывается один раз при регистрации или перевыпуске
PropertyСвойствоValueЗначение
FormatФорматURL-safe string, 32 bytes entropy
PrefixПрефиксNone (plain key)Не используется
StorageХранениеServer stores SHA-256 hash; plaintext only on clientНа сервере — SHA-256 hash; plaintext только у клиента

Deposits — TON & USDT TONДепозиты — TON & USDT TON

Top up your unique deposit_address on TON mainnet. Minimum deposit: 5 TON or 5 USDT. Deposit fee: 0.5%.Пополните уникальный deposit_address мерчанта в сети TON mainnet. Минимальный депозит: 5 TON или 5 USDT. Комиссия депозита: 0.5%.

AssetАктивHow to sendКак отправитьCredit timeЗачисление
TONNative TON to deposit addressNative TON на deposit-адрес~30 sec, automatic~30 сек, автоматически
USDT TONUSDT jetton to deposit addressJetton USDT на deposit-адрес~30 sec, automatic~30 сек, автоматически

USDT jetton contract (only accepted)USDT jetton контракт (только он принимается)

EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs

Wallet verification suffix: …Id_sDs. Other jettons are not credited.Суффикс для проверки в кошельке: …Id_sDs. Другие jetton не зачисляются.

payment_method for purchasespayment_method при покупке

payment_methodDebited fromСписание
tonton_balance
usdt_tonusdt_balance

Error codesКоды ошибок

Errors are returned as JSON: {"detail": "message"}Ошибки возвращаются как JSON: {"detail": "message"}

HTTPWhenКогдаExample detailПример detail
400Invalid parametersНевалидные параметрыquantity must be between 50 and 1000000
401Missing or invalid API keyНет или неверный API keyInvalid API key
402Insufficient balanceНедостаточно балансаInsufficient usdt balance. Need 0.82, have 0.5
404Transaction not foundТранзакция не найденаTransaction not found

Order statusesСтатусы заказа

pendingprocessingpayingcompleted | failed

On failed, funds are automatically refunded to merchant balance.При failed средства автоматически возвращаются на баланс мерчанта.

Integration guideРуководство по интеграции

  1. Get API key from Telegram botПолучите API key в Telegram-боте
  2. GET /api/balancesaveсохраните deposit_address
  3. Top up TON or USDT (contract …Id_sDs)Пополните TON или USDT (контракт …Id_sDs)
  4. POST /api/searchverify recipientпроверьте получателя
  5. GET /api/pricesget live quoteполучите live quote
  6. POST /api/purchase withс idempotency_key
  7. PollPoll GET /api/purchase/transaction/{id} untilдо completed

Endpoints

GET /api/balance

Returns merchant balance, deposit address, and USDT contract info.Баланс мерчанта, deposit-адрес и данные USDT-контракта.

Parameters

NameTypeInRequiredDescription
X-API-KeystringheaderYesMerchant API key

200 Success

{
  "ton_balance": 1.25,
  "usdt_balance": 9.14,
  "deposit_address": "UQDVv_pPqr8U...",
  "usdt_jetton_master": "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
  "usdt_jetton_master_suffix": "Id_sDs",
  "mainnet_balance": 1.25,
  "testnet_balance": 0.0
}

401 Unauthorized

{ "detail": "Invalid API key" }

Examples

cURL
curl "https://api.fragment-api.io/api/balance" \
  -H "X-API-Key: YOUR_API_KEY"
JavaScript
const balance = await fetch("https://api.fragment-api.io/api/balance", {
  headers: { "X-API-Key": process.env.FRAGMENT_API_KEY }
}).then(r => r.json());
Python
import requests

balance = requests.get(
    "https://api.fragment-api.io/api/balance",
    headers={"X-API-Key": "YOUR_API_KEY"},
).json()
GET /api/prices

Live Stars quote from Fragment for a given quantity and payment method. Price = product cost + on-chain gas.Live quote Stars из Fragment для указанного количества и способа оплаты. Цена = стоимость продукта + gas в сети.

Parameters

NameTypeInRequiredDescription
product_typestringqueryYesstars | premium
quantitystringqueryNoStars: 50–1000000. Premium: 3, 6, or 12 monthsStars: 50–1000000. Premium: 3, 6 или 12 месяцев
recipientstringqueryNo*Telegram username (required in live mode)Telegram username (обязателен в live mode)
payment_methodstringqueryNoton | usdt_ton. Default: usdt_ton
X-API-KeystringheaderYesMerchant API key

200 Success

{
  "product_type": "stars",
  "item_name": "50 Telegram Stars",
  "price": 0.7875,
  "gas_fee": 0.07,
  "total": 0.8575,
  "currency": "USDT",
  "payment_method": "usdt_ton"
}

400 Bad Request

{ "detail": "quantity must be one of premium months: 3, 6, 12" }

Examples

curl "https://api.fragment-api.io/api/prices?product_type=stars&quantity=50&recipient=durov&payment_method=usdt_ton" \
  -H "X-API-Key: YOUR_API_KEY"
GET /api/prices/list

Price list for common volumes (50, 100, 500, 1000 stars) in TON and USDT TON.Прайс-лист для типовых объёмов (50, 100, 500, 1000 stars) в TON и USDT TON.

Parameters

NameTypeInRequiredDescription
X-API-KeystringheaderYesMerchant API key

200 Success

[ { "product_type": "stars", "item_name": "50 Telegram Stars", "total": 0.575, "...": "..." } ]

Examples

curl "https://api.fragment-api.io/api/prices/list" -H "X-API-Key: YOUR_API_KEY"
POST /api/search

Verify Telegram Stars recipient exists via Fragment.Проверка существования Telegram-получателя Stars через Fragment.

Parameters (body JSON)

NameTypeRequiredDescription
product_typestringYesstars | premium
querystringYesUsername (with or without @)
quantitystringNoOptional compat field
payment_methodstringNoOptional compat field

200 — found

{ "ok": true, "found": { "recipient": "durov", "name": "Pavel Durov", "myself": false } }

200 — not found

{ "ok": false, "found": null }

Examples

curl -X POST "https://api.fragment-api.io/api/search" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"product_type":"stars","query":"durov","quantity":"50"}'
POST /api/purchase

Create a Stars purchase order. Balance is debited when the worker processes the order.Создание заказа на покупку Telegram Stars. Списание с баланса при обработке worker'ом.

Parameters (body JSON)

NameTypeRequiredDescription
product_typestringYesstars | premium
recipientstringYesTelegram username without @
quantitystringYes50–1000000 (string)
payment_methodstringNoton | usdt_ton. Default: usdt_ton
idempotency_keystringYesUnique order key; retries return the same order

201 Created

{
  "transaction_id": "ord_a1b2c3d4e5f6...",
  "status": "pending",
  "recipient": "durov",
  "item_name": "50 Telegram Stars",
  "item_price": 0.8575,
  "payment_method": "usdt_ton"
}

402 Payment Required

{ "detail": "Insufficient usdt balance. Need 0.8575, have 0.5" }

Examples

curl -X POST "https://api.fragment-api.io/api/purchase" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"product_type":"stars","recipient":"durov","quantity":"50","payment_method":"usdt_ton","idempotency_key":"order-1001"}'
GET /api/purchase/transaction/{transaction_id}

Get order status by transaction_id from purchase response.Статус заказа по transaction_id из ответа purchase.

Parameters

NameTypeInRequiredDescription
transaction_idstringpathYesID like ord_...
X-API-KeystringheaderYesMerchant API key

200 Success

{ "transaction_id": "ord_...", "status": "completed", "ton_tx_id": "live:...", "...": "..." }

404 Not Found

{ "detail": "Transaction not found" }
GET /api/purchase/by-idempotency-key/{key}

Find order by your idempotency_key.Найти заказ по вашему idempotency_key.

200 Success

Same Transaction object as /api/purchase/transaction/{id}.Тот же объект Transaction, что и в /api/purchase/transaction/{id}.

404 Not Found

{ "detail": "Transaction not found" }
GET /api/purchase/history

Paginated order history for the merchant.История заказов мерчанта с пагинацией.

Parameters

NameTypeInRequiredDescription
limitintegerqueryNo1–100, default 50
offsetintegerqueryNoDefault 0
X-API-KeystringheaderYesMerchant API key

200 Success

{ "transactions": [ { "...": "..." } ], "limit": 50, "offset": 0 }
POST /merchants/topup

Get deposit address and USDT contract info for top-up.Получить deposit-адрес и данные USDT-контракта для пополнения.

Parameters (body JSON)

NameTypeRequiredDescription
currencystringNoton | usdt. Default: ton
amountfloatNoInformational only

201 Created

{
  "wallet_address": "UQDVv_pPqr8U...",
  "currency": "usdt",
  "usdt_jetton_master": "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
  "usdt_jetton_master_suffix": "Id_sDs",
  "note": "Send TON to this address. For USDT TON use jetton contract …Id_sDs only."
}

Legacy v1

Deprecated endpoints for backward compatibility. Use /api/* for new integrations.Deprecated endpoints для обратной совместимости. Для новых интеграций используйте /api/*.

MethodPathDescription
GET/v1/balanceBalanceБаланс (ton, usdt)
POST/v1/stars/searchSearch recipientПоиск получателя
POST/v1/stars/quoteQuoteQuote
POST/v1/stars/purchasePurchasePurchase (asset: ton|usdt)
GET/v1/orders/{order_id}Order statusСтатус заказа
POST/v1/withdrawWithdrawal requestЗаявка на вывод

AI integrationAI интеграция

For LLM agents (Cursor, Claude, GPT)Для LLM-агентов (Cursor, Claude, GPT)

Machine-readable guide:Машиночитаемая выжимка: llms.txt

OpenAPI: openapi.json

System prompt

You integrate fragment-api.io — provider API for Telegram Stars.

Base URL: https://api.fragment-api.io
Auth: X-API-Key: <merchant_api_key>

USDT deposits: jetton EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs (suffix …Id_sDs)

Payment methods: "ton" | "usdt_ton"

Workflow:
1. GET /api/balance
2. POST /api/search
3. GET /api/prices?product_type=stars&quantity=50&recipient=durov&payment_method=usdt_ton
4. POST /api/purchase with idempotency_key
5. Poll GET /api/purchase/transaction/{transaction_id} until completed

Errors: 401 auth, 402 insufficient balance, 404 not found
Min quantity: 50 stars (quantity is string)
OpenAPI: https://api.fragment-api.io/openapi.json

Agent checklistЧеклист для агентов

  • Always use idempotency_key for purchasesВсегда используйте idempotency_key при покупках
  • Check balance for the correct currency before purchaseПроверяйте баланс нужной валюты перед purchase
  • USDT — only contract suffix Id_sDsUSDT — только контракт с суффиксом Id_sDs
  • On 402 — top up deposit_addressПри 402 — пополните deposit_address
  • Poll every 2–5 sec until terminal statusPoll interval: 2–5 сек до terminal status

OpenAPI