StaticGramBot API

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

Use this method to get the token of a managed bot. Returns the token as String on success.

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

full flow: reply keyboard request_managed_bot (→ keyboardButtonRequestPeer + requestPeerTypeCreateBot{bot_managed, suggested_name, suggested_username}) or savePreparedKeyboardButton; the user creates the bot with bots.createBot(manager_id) (manager must have Bot Management Mode, else MANAGER_PERMISSION_MISSING; non-bot → MANAGER_INVALID) and owns it; managed_bot (ManagedBotUpdated {user = owner, bot}) on creation and on every token change; messages.sendBotRequestedPeer with the new bot → service message messageActionManagedBotCreated in the user↔manager chat (both sides), Bot API Message.managed_bot_created; the manager bot can also read/rotate the token over MTProto bots.exportBotToken. managed_bot is delivered by default (not opt-in). Not implemented: owner change (no bot ownership transfer in StaticGram), MTProto updateManagedBot (no qts updates for MTProto bot sessions)

Параметры

user_idIntegerобязательный
User identifier of the managed bot whose token will be returned

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

curl
curl "https://api.staticgram.top/bot$TOKEN/getManagedBotToken" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": 123456789
  }'
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.get_managed_bot_token(user_id=123456789)
JavaScript
const res = await fetch(`https://api.staticgram.top/bot${TOKEN}/getManagedBotToken`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "user_id": 123456789
  }),
});
const data = await res.json();

Ответ (String)

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

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