StaticGramBot API

sendGramInvoiceПоддерживается

Расширение StaticGram (в официальном Bot API его нет). Отправляет счёт в GRAM — внутренней валюте StaticGram: те же параметры, что у sendInvoice, но без currency, prices и provider_token, а цена передаётся одним полем amount в GRAM ("1.5", "0,01", 2.5) или nanoton_amount в нанотонах. Под капотом это обычный счёт sendInvoice с currency "TON": оплата, pre_checkout_query, successful_payment, refundGramPayment и баланс бота работают так же. On success, the sent Message is returned.

Особенности StaticGram

Метод StaticGram. Цена: ровно одно из amount (GRAM, строка или число, до 9 знаков после запятой, запятая или точка) и nanoton_amount; от 0.01 до 10000 GRAM. Счёт создаётся с currency "TON": в invoice, pre_checkout_query, successful_payment и refunded_payment приходят currency "TON", total_amount в нанотонах и gram_amount — сумма в GRAM строкой ("1.5"). Ошибки: AMOUNT_INVALID (нет цены, обе цены, не число, больше 9 знаков), AMOUNT_TOO_SMALL, AMOUNT_TOO_LARGE, CURRENCY_INVALID (currency не GRAM/TON), PRICES_INVALID (передан prices или label длиннее 64), PAYMENT_PROVIDER_INVALID (передан provider_token). Возврат — refundGramPayment, баланс — getMyGramBalance, вывод — withdrawGramBalance. Подробнее — раздел «Оплата» → «Счета в GRAM».

Параметры

chat_idInteger or Stringобязательный
Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username
message_thread_idIntegerнеобязательный
Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only
titleStringобязательный
Product name, 1-32 characters
descriptionStringобязательный
Product description, 1-255 characters
payloadStringобязательный
Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
amountString or Floatнеобязательный
Цена в GRAM: строка или число — "1.5", "0,01", 2.5. Не больше 9 знаков после запятой, от 0.01 до 10000 GRAM. Обязателен один из amount или nanoton_amount.
nanoton_amountIntegerнеобязательный
Цена в нанотонах (1 GRAM = 1000000000), от 10000000 до 10000000000000. Вместо amount.
labelStringнеобязательный
Подпись позиции в счёте, 1–64 символа. Не передана — используется title.
start_parameterStringнеобязательный
Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter.
photo_urlStringнеобязательный
URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
photo_sizeIntegerнеобязательный
Photo size in bytes
photo_widthIntegerнеобязательный
Photo width
photo_heightIntegerнеобязательный
Photo height
disable_notificationBooleanнеобязательный
Sends the message silently . Users will receive a notification with no sound.
protect_contentBooleanнеобязательный
Protects the contents of the sent message from forwarding and saving
allow_paid_broadcastBooleanнеобязательный
Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance.
message_effect_idStringнеобязательный
Unique identifier of the message effect to be added to the message; for private chats only
reply_parametersReplyParametersнеобязательный
Description of the message to reply to
reply_markupInlineKeyboardMarkupнеобязательный
A JSON-serialized object for an inline keyboard . If empty, one 'Pay total price ' button will be shown. If not empty, the first button must be a Pay button.

Ошибки

Ошибка приходит как {"ok": false, "error_code": 400, "description": "Bad Request: КОД: пояснение"}, если не указано иное.

ОшибкаКогда
AMOUNT_INVALIDнет цены, переданы и amount, и nanoton_amount, не число или больше 9 знаков после запятой
AMOUNT_TOO_SMALLменьше 0.01 GRAM (10000000 нанотонов)
AMOUNT_TOO_LARGEбольше 10 000 GRAM
CURRENCY_INVALIDпередан currency, отличный от GRAM/TON
PRICES_INVALIDпередан prices или label длиннее 64 символов
PAYMENT_PROVIDER_INVALIDпередан provider_token
…остальные ошибки как у sendInvoice / createInvoiceLink (INVOICE_TITLE_INVALID и т. п.)

Пример запроса

curl
curl "https://api.staticgram.top/bot$TOKEN/sendGramInvoice" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 123456789,
    "title": "Премиум-доступ",
    "description": "30 дней без ограничений",
    "payload": "premium-30d-user-123",
    "amount": "1.5"
  }'
aiogram 3
from aiogram import Bot
from aiogram.client.session.aiohttp import AiohttpSession
from aiogram.client.telegram import TelegramAPIServer
from aiogram.methods.base import TelegramMethod
from aiogram.types import InlineKeyboardMarkup, Message

# Метода StaticGram нет в aiogram: описываем его сами, bot(...) отправит запрос как обычно.
class SendGramInvoice(TelegramMethod[Message]):
    __returning__ = Message
    __api_method__ = "sendGramInvoice"

    chat_id: int | str
    title: str
    description: str
    payload: str
    amount: str | float | None = None        # "1.5", "0,01", 2.5
    nanoton_amount: int | None = None         # или цена в нанотонах
    label: str | None = None
    photo_url: str | None = None
    message_thread_id: int | None = None
    reply_markup: InlineKeyboardMarkup | None = None

session = AiohttpSession(api=TelegramAPIServer.from_base("https://api.staticgram.top"))
bot = Bot(TOKEN, session=session)

msg = await bot(SendGramInvoice(
    chat_id=123456789, title="Премиум-доступ", description="30 дней без ограничений",
    payload="premium-30d-user-123", amount="1.5",
))
print(msg.invoice.total_amount)  # 1500000000 (нанотоны), currency == "TON"
JavaScript
const res = await fetch(`https://api.staticgram.top/bot${TOKEN}/sendGramInvoice`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    chat_id: 123456789,
    title: "Премиум-доступ",
    description: "30 дней без ограничений",
    payload: "premium-30d-user-123",
    amount: "1.5",
  }),
});
const data = await res.json();

Ответ (Message)

JSON
{
  "ok": true,
  "result": {
    "message_id": 1,
    "date": 1790000000,
    "chat": {
      "id": 1780243423,
      "type": "private"
    }
  }
}

Описания методов и типов взяты из официальной документации Telegram Bot API (Bot API 10.3). Адрес API: https://api.staticgram.top