-
-
Notifications
You must be signed in to change notification settings - Fork 0
API
bobberdolle1 edited this page Jan 6, 2026
·
1 revision
Mini App использует REST API для управления ботом.
Все запросы требуют заголовок:
X-Telegram-Init-Data: <initData from Telegram WebApp>
Сервер валидирует подпись и проверяет user_id == OWNER_ID.
GET /api/statusResponse:
{
"ollama": {
"connected": true,
"model": "llama3.2"
},
"database": {
"connected": true,
"path": "sqlite:persona_forge.db"
},
"queue": {
"current": 0,
"max": 3
},
"uptime_seconds": 3600,
"paused": false
}GET /api/personasResponse:
[
{
"id": 1,
"name": "Default",
"prompt": "You are a helpful assistant",
"display_name": null,
"triggers": null,
"created_at": "2024-01-01T00:00:00Z"
}
]POST /api/personas
Content-Type: application/json
{
"name": "Philosopher",
"prompt": "You are Socrates...",
"display_name": "Сократ",
"triggers": "философия,смысл"
}PUT /api/personas/:id
Content-Type: application/json
{
"name": "Updated Name",
"prompt": "Updated prompt",
"display_name": "New Display Name",
"triggers": "new,triggers"
}DELETE /api/personas/:idPOST /api/personas/:id/activate?chat_id=123456GET /api/chatsResponse:
[
{
"chat_id": -123456789,
"title": "My Group",
"active_persona_id": 1,
"rag_enabled": true,
"triggers": "бот,помоги",
"response_mode": "mention_only"
}
]PUT /api/chats/:id
Content-Type: application/json
{
"active_persona_id": 2,
"rag_enabled": false,
"triggers": "new,triggers",
"response_mode": "all_messages"
}GET /api/configResponse:
{
"ollama_chat_model": "llama3.2",
"temperature": 0.7,
"max_tokens": 2048,
"vision_enabled": true,
"voice_enabled": true,
"web_search_enabled": true
}POST /api/config
Content-Type: application/json
{
"ollama_chat_model": "mistral",
"temperature": 0.5,
"max_tokens": 4096,
"vision_enabled": false
}GET /api/securityResponse:
{
"injection_detection_enabled": true,
"rate_limiting_enabled": true,
"max_strikes": 5
}GET /api/security/users/:idResponse:
{
"user_id": 123456789,
"strikes": 2,
"blocked": false,
"blocked_until": null,
"last_violation": "2024-01-01T12:00:00Z"
}POST /api/security/users/:id/block
Content-Type: application/json
{
"duration_minutes": 60
}POST /api/security/users/:id/unblockGET /api/pauseResponse:
{
"paused": false
}POST /api/pauseResponse:
{
"paused": true
}| Код | Описание |
|---|---|
| 200 | OK |
| 201 | Created |
| 400 | Bad Request |
| 401 | Unauthorized (invalid initData) |
| 403 | Forbidden (not owner) |
| 404 | Not Found |
| 500 | Internal Server Error |
# Получить статус
curl -H "X-Telegram-Init-Data: $INIT_DATA" \
http://localhost:8080/api/status
# Создать персону
curl -X POST \
-H "X-Telegram-Init-Data: $INIT_DATA" \
-H "Content-Type: application/json" \
-d '{"name":"Test","prompt":"Test prompt"}' \
http://localhost:8080/api/personas
# Заблокировать пользователя
curl -X POST \
-H "X-Telegram-Init-Data: $INIT_DATA" \
-H "Content-Type: application/json" \
-d '{"duration_minutes":60}' \
http://localhost:8080/api/security/users/123456/block➡️ Далее: Contributing
GitHub · Issues · Discussions