Skip to content

Latest commit

 

History

History
224 lines (176 loc) · 3.31 KB

File metadata and controls

224 lines (176 loc) · 3.31 KB

P2A-Bot v2 API Documentation

Complete REST API reference for P2A-Bot Java Edition.

🔌 API Base URL

http://localhost:8080/api

🏥 Health & Info

Health Check

GET /health

Returns bot status and version info.

Bot Information

GET /health/info

Returns detailed bot information.

Database Status

GET /database/status

Check SQLite database connection.

📝 Notes API

Save Note

POST /bot/{chatId}/notes?key=greeting&content=Hello%20everyone!

Get Note

GET /bot/{chatId}/notes/{key}

List All Notes

GET /bot/{chatId}/notes

Delete Note

DELETE /bot/{chatId}/notes/{key}

⚠️ Warnings API

Add Warning

POST /bot/{chatId}/warnings/{userId}?reason=Spam

Get Warning Count

GET /bot/{chatId}/warnings/{userId}

Clear Warnings

DELETE /bot/{chatId}/warnings/{userId}

🔧 Filters API

Add Filter

POST /bot/{chatId}/filters?pattern=bad&replacement=***&regex=false

List Filters

GET /bot/{chatId}/filters

Delete Filter

DELETE /bot/{chatId}/filters/{filterId}

📊 Stats API

Get Chat Stats

GET /stats/{chatId}

Get Detailed Stats

GET /bot/{chatId}/stats

Increment Stat

POST /bot/{chatId}/stats/increment/{action}

Actions: message, warning, ban, kick

💾 Database API

List Tables

GET /database/tables

Get Schema

GET /database/schema

Initialize Database

POST /database/init

🔔 Telegram Webhook

Receive Update

POST /webhook/telegram

Telegram sends updates to this endpoint.

📚 Example Requests

Save a Group Greeting

curl -X POST http://localhost:8080/api/bot/12345/notes \
  -d "key=greeting" \
  -d "content=Welcome to our group!"

Warn a User

curl -X POST http://localhost:8080/api/bot/12345/warnings/67890 \
  -d "reason=Spam"

Get Chat Statistics

curl http://localhost:8080/api/bot/12345/stats

List All Notes

curl http://localhost:8080/api/bot/12345/notes

Check Database Status

curl http://localhost:8080/api/database/status

🔄 Response Format

All responses follow this format:

Success Response

{
  "status": "success",
  "data": { /* response data */ },
  "timestamp": 1234567890
}

Note Response

{
  "id": "uuid-string",
  "chatId": 12345,
  "noteKey": "greeting",
  "noteContent": "Welcome!",
  "createdAt": "2024-11-25T10:30:00",
  "updatedAt": "2024-11-25T10:30:00"
}

Stats Response

{
  "id": 1,
  "chatId": 12345,
  "totalMessages": 1500,
  "usersWarned": 5,
  "usersKicked": 2,
  "usersBanned": 1,
  "notesSaved": 8,
  "createdAt": "2024-11-25T10:00:00",
  "updatedAt": "2024-11-25T10:30:00"
}

🔐 Authentication

No authentication required (open API).

⚡ Rate Limits

No rate limits configured (unlimited requests).

🚨 Error Codes

  • 200 - OK
  • 400 - Bad Request
  • 404 - Not Found
  • 500 - Server Error

📱 TypeScript Version API

The TypeScript version uses Mastra framework:

POST /api/workflow/trigger
GET /api/agent/status

See TypeScript API docs for details.


API Version: 2.0.0
Last Updated: November 25, 2024