StaticGramBot API

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

Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success.

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

paid from the bot Stars balance through the star gift purchase aggregate; users and channels

Параметры

user_idIntegerнеобязательный
Required if chat_id is not specified. Unique identifier of the target user who will receive the gift.
chat_idInteger or Stringнеобязательный
Required if user_id is not specified. Unique identifier for the chat or username of the channel (in the format @username) that will receive the gift.
gift_idStringобязательный
Identifier of the gift; limited gifts can't be sent to channel chats
pay_for_upgradeBooleanнеобязательный
Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
textStringнеобязательный
Text that will be shown along with the gift; 0-128 characters
text_parse_modeStringнеобязательный
Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.
text_entitiesArray of MessageEntityнеобязательный
A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “custom_emoji”, and “date_time” are ignored.

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

curl
curl "https://api.staticgram.top/bot$TOKEN/sendGift" \
  -H "Content-Type: application/json" \
  -d '{
    "gift_id": "<gift_id>"
  }'
aiogram 3
from aiogram import Bot
from aiogram.client.session.aiohttp import AiohttpSession
from aiogram.client.telegram import TelegramAPIServer

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

result = await bot.send_gift(gift_id="<gift_id>")
JavaScript
const res = await fetch(`https://api.staticgram.top/bot${TOKEN}/sendGift`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "gift_id": "<gift_id>"
  }),
});
const data = await res.json();

Ответ (True)

JSON
{
  "ok": true,
  "result": true
}

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