Bot statistics and management API
Bot data, orders, income, and settings via the Bot API key.
With a Bot API key your server can get the bot's statistics and change its settings — without opening @mgram_robot. Handy if you have many bots or your own control panel.
The key
- The Bot API key is in the bot card: “Settings” → “API key”.
- Every request is sent with the header
Authorization: Bearer YOUR_BOT_API_KEY. POST /key/regenerateissues a new key. The full key is shown only once; the old one stops working immediately.
What you can get
| Method | What it returns |
|---|---|
GET /bot | Bot information |
GET /audience | The audience without user IDs: total, Premium, verified, with avatar, bio, and gifts, blocked, geo |
GET /orders | Broadcast orders the bot took part in |
GET /orders/{id} and /orders/{id}/report | Broadcast details and report |
GET /reply-ads/orders | Reply Ads orders in the bot |
GET /stats/mailings and /stats/mailings/today | Broadcasts by day and today |
GET /stats/reply-ads | Reply Ads statistics |
GET /stats/income and /stats/income/today | Income by day and today |
GET /earnings | Earnings: today, pending, total |
GET /balance | The owner's balance |
What you can change
| Method | What it does |
|---|---|
POST /bot/settings | Slots, speed, catalog, own orders, broadcast participation, catalog price, Reply Ads |
GET /bot/time_slots | Available slots and the current selection |
POST /bot/stop_mailing | Turns off participation in new broadcasts; assigned orders continue |
POST /bot/token | Replaces the Telegram bot token — only with a token of the same bot |
Only settings available to the owner in the MGRAM interface can be changed, and only with allowed values.
Errors
All errors come in one format. Main codes:
| Code | What it means |
|---|---|
| 400 | Bad request — check the parameters |
| 401 | Key not accepted |
| 403 | No access to the operation |
| 404 | Not found |
| 409 | Request conflict |
| 429 | Too many requests — retry later |
| 5xx | Temporary service error — retry later |
Keep the Bot API key only on your server. Don't put it into the code of a Mini App, website, or client app.
Parameters and response examples for every method are at api.mgram.biz.