Skip to content

Admin API 🔒 ​

Administrative endpoints for server management. All endpoints require admin privileges.

Get Server Settings ​

Retrieve current server configuration.

Endpoint: GET /api/admin/settings

Authentication: Required (JWT, Admin)

Success Response (200):

json
{
  "success": true,
  "settings": {
    "serverName": "My Minecraft Server",
    "maxPlayers": 20,
    "difficulty": "NORMAL",
    "gameMode": "SURVIVAL",
    "pvpEnabled": true,
    "whitelist": {
      "enabled": true,
      "autoApprove": false
    },
    "notifications": {
      "unregisteredInterval": 300,
      "enabled": true
    },
    "discord": {
      "enabled": true,
      "webhookUrl": "https://discord.com/api/webhooks/..."
    },
    "economy": {
      "currencySymbol": "💰",
      "startingBalance": 1000.0
    }
  }
}

Example:

bash
curl http://localhost:8080/api/admin/settings \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Update Server Settings ​

Update server configuration.

Endpoint: POST /api/admin/settings

Authentication: Required (JWT, Admin)

Request Body:

json
{
  "serverName": "Updated Server Name",
  "notifications": {
    "unregisteredInterval": 600
  }
}

Success Response (200):

json
{
  "success": true,
  "message": "Settings updated successfully",
  "updated": ["serverName", "notifications.unregisteredInterval"]
}

Example:

bash
curl -X POST http://localhost:8080/api/admin/settings \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"serverName": "New Name"}'

List All Users ​

Get a list of all registered users.

Endpoint: GET /api/admin/users?page=1&limit=50

Authentication: Required (JWT, Admin)

Query Parameters:

  • page - Page number (default: 1)
  • limit - Users per page (default: 50, max: 100)
  • search - Search by username (optional)

Success Response (200):

json
{
  "success": true,
  "users": [
    {
      "id": 1,
      "username": "player123",
      "minecraftUsername": "Player123",
      "email": "player@example.com",
      "isAdmin": false,
      "isWhitelisted": true,
      "createdAt": "2024-01-15T10:30:00Z",
      "lastLogin": "2024-01-20T14:25:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 150,
    "pages": 3
  }
}

Example:

bash
curl "http://localhost:8080/api/admin/users?search=player" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

View Connection Logs ​

View player connection history.

Endpoint: GET /api/admin/connections?limit=100

Authentication: Required (JWT, Admin)

Query Parameters:

  • limit - Number of logs (default: 100, max: 500)
  • username - Filter by username (optional)

Success Response (200):

json
{
  "success": true,
  "connections": [
    {
      "id": 12345,
      "username": "Player123",
      "action": "LOGIN",
      "ipAddress": "192.168.1.100",
      "timestamp": "2024-01-20T14:25:00Z",
      "success": true
    },
    {
      "id": 12344,
      "username": "Player456",
      "action": "LOGOUT",
      "ipAddress": "192.168.1.101",
      "timestamp": "2024-01-20T14:20:00Z",
      "success": true
    }
  ]
}

Example:

bash
curl "http://localhost:8080/api/admin/connections?limit=50" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Test Discord Webhook ​

Test Discord webhook configuration.

Endpoint: POST /api/admin/discord/test

Authentication: Required (JWT, Admin)

Success Response (200):

json
{
  "success": true,
  "message": "Test message sent to Discord"
}

Example:

bash
curl -X POST http://localhost:8080/api/admin/discord/test \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Error Responses:

  • 400 - Discord webhook not configured
  • 500 - Failed to send message

Get Messages ​

Retrieve server messages or announcements.

Endpoint: GET /api/admin/messages

Authentication: Required (JWT, Admin)

Success Response (200):

json
{
  "success": true,
  "messages": [
    {
      "id": 1,
      "type": "ANNOUNCEMENT",
      "content": "Server maintenance at 3 PM",
      "createdAt": "2024-01-20T10:00:00Z",
      "expiresAt": "2024-01-21T15:00:00Z"
    }
  ]
}

Example:

bash
curl http://localhost:8080/api/admin/messages \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Send Message to Player ​

Send a message to an online player.

Endpoint: POST /api/admin/messages/send

Authentication: Required (JWT, Admin)

Request Body:

json
{
  "username": "Player123",
  "message": "Welcome to the server!"
}

Success Response (200):

json
{
  "success": true,
  "message": "Message sent to Player123"
}

Example:

bash
curl -X POST http://localhost:8080/api/admin/messages/send \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "Player123",
    "message": "Hello!"
  }'

Error Responses:

  • 400 - Missing username or message
  • 404 - Player not online

Schedule Server Restart ​

Schedule a server restart with countdown.

Endpoint: POST /api/admin/restart

Authentication: Required (JWT, Admin)

Request Body:

json
{
  "delay": 300,
  "reason": "Server maintenance"
}

Parameters:

  • delay - Delay in seconds (required)
  • reason - Restart reason (optional)

Success Response (200):

json
{
  "success": true,
  "message": "Server restart scheduled in 5 minutes",
  "restartAt": "2024-01-20T15:05:00Z"
}

Example:

bash
curl -X POST http://localhost:8080/api/admin/restart \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "delay": 300,
    "reason": "Scheduled maintenance"
  }'

Code Examples ​

TypeScript ​

typescript
class AdminAPI {
  constructor(private baseUrl: string, private adminToken: string) {}
  
  async getSettings() {
    const response = await fetch(`${this.baseUrl}/api/admin/settings`, {
      headers: { 'Authorization': `Bearer ${this.adminToken}` }
    });
    return await response.json();
  }
  
  async updateSettings(settings: Record<string, any>) {
    const response = await fetch(`${this.baseUrl}/api/admin/settings`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.adminToken}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(settings)
    });
    return await response.json();
  }
  
  async getUsers(page = 1, limit = 50, search?: string) {
    const params = new URLSearchParams({
      page: page.toString(),
      limit: limit.toString()
    });
    if (search) params.append('search', search);
    
    const response = await fetch(
      `${this.baseUrl}/api/admin/users?${params}`,
      {
        headers: { 'Authorization': `Bearer ${this.adminToken}` }
      }
    );
    return await response.json();
  }
  
  async scheduleRestart(delay: number, reason?: string) {
    const response = await fetch(`${this.baseUrl}/api/admin/restart`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.adminToken}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ delay, reason })
    });
    return await response.json();
  }
}

Python ​

python
class AdminAPI:
    def __init__(self, base_url, admin_token):
        self.base_url = base_url
        self.headers = {'Authorization': f'Bearer {admin_token}'}
    
    def get_settings(self):
        response = requests.get(
            f'{self.base_url}/api/admin/settings',
            headers=self.headers
        )
        return response.json()
    
    def update_settings(self, settings):
        response = requests.post(
            f'{self.base_url}/api/admin/settings',
            headers={**self.headers, 'Content-Type': 'application/json'},
            json=settings
        )
        return response.json()
    
    def get_users(self, page=1, limit=50, search=None):
        params = {'page': page, 'limit': limit}
        if search:
            params['search'] = search
        
        response = requests.get(
            f'{self.base_url}/api/admin/users',
            headers=self.headers,
            params=params
        )
        return response.json()
    
    def schedule_restart(self, delay, reason=None):
        payload = {'delay': delay}
        if reason:
            payload['reason'] = reason
        
        response = requests.post(
            f'{self.base_url}/api/admin/restart',
            headers={**self.headers, 'Content-Type': 'application/json'},
            json=payload
        )
        return response.json()

Notes ​

  • All admin endpoints require admin JWT token
  • Admin status verified via Minecraft operator status
  • Settings changes apply immediately (no restart required)
  • Connection logs retained for 30 days
  • Discord webhooks support custom messages and embeds
  • Restart countdown displayed to all players via boss bar

Released under the MIT License.