Skip to content

Web API Module

The Web API Module provides a comprehensive REST API for external integrations and web interfaces.

  • REST API - Full REST API implementation
  • Authentication - Token-based authentication
  • Rate Limiting - Prevent API abuse
  • CORS Support - Cross-origin requests
  • JSON Responses - Structured API responses
  • Player Management - Player information and history
  • Moderation Actions - Ban, mute, kick via API
  • Case Management - Case lookup and management
  • IP Analysis - IP-based player analysis
  • Alt Detection - Find alternate accounts
  • Statistics - Server and moderation statistics
Terminal window
/zenith token generate [duration]

Examples:

Terminal window
/zenith token generate # Permanent token
/zenith token generate 1h # 1 hour token
/zenith token generate 7d # 7 day token

Get detailed player information.

Parameters:

  • name (string) - Player name
  • uuid (string) - Player UUID

Example:

Terminal window
curl -H "Authorization: Bearer your-token" \
"http://server:3000/zenith/api/player/getinfo?name=Player123"

Get player’s punishment history.

Parameters:

  • name (string) - Player name
  • uuid (string) - Player UUID
  • limit (int) - Max results (default: 50, max: 100)
  • offset (int) - Skip results (default: 0)

Example:

Terminal window
curl -H "Authorization: Bearer your-token" \
"http://server:3000/zenith/api/player/history?name=Player123&limit=10"

Ban a player via API.

Parameters:

  • player (string) - Player name
  • reason (string) - Ban reason
  • duration (string) - Duration (optional)

Example:

Terminal window
curl -X POST -H "Authorization: Bearer your-token" \
"http://server:3000/zenith/api/ban?player=Player123?reason=Cheating&duration=7d"

Mute a player via API.

Parameters:

  • player (string) - Player name
  • reason (string) - Mute reason
  • duration (string) - Duration (optional)

Example:

Terminal window
curl -X POST -H "Authorization: Bearer your-token" \
"http://server:3000/zenith/api/mute?player=Player123?reason=Spam&duration=1h"

Warn a player via API.

Parameters:

  • player (string) - Player name
  • template (string) - Template name
  • reason (string) - Optional custom reason

Example:

Terminal window
curl -X POST -H "Authorization: Bearer your-token" \
"http://server:3000/zenith/api/warn?player=Player123&template=spam?reason=Excessive chat spam"

Get warning history for a player.

Parameters:

  • player (string) - Player name
  • limit (int) - Max results (default: 50, max: 100)
  • offset (int) - Skip results (default: 0)

Example:

Terminal window
curl -H "Authorization: Bearer your-token" \
"http://server:3000/zenith/api/warn/history?player=Player123&limit=10"

Get available warning templates.

Example:

Terminal window
curl -H "Authorization: Bearer your-token" \
"http://server:3000/zenith/api/warn/templates"
modules/web-api.yml
enabled: true
settings:
port: 3000
host: "0.0.0.0"
rate-limit: 100
rate-limit-window: 60
cors-enabled: true
cors-origins:
- "http://localhost:3000"
- "https://yourdomain.com"
auth:
token-length: 32
token-expiry: 30d
require-permission: "zenith.api.access"
rate-limiting:
enabled: true
requests-per-minute: 100
burst-limit: 20
whitelist:
- "127.0.0.1"
- "::1"
PermissionDescription
zenith.api.accessAccess to API
zenith.api.token.useUse token commands
zenith.api.token.generateGenerate tokens
zenith.api.token.listList tokens
zenith.api.token.revokeRevoke tokens
permissions:
- zenith.api.access: true
- zenith.api.token.use: true
- zenith.api.token.generate: true
- zenith.api.token.list: true
- zenith.api.token.revoke: true

What they can do:

  • ✅ Full API access
  • ✅ Generate tokens
  • ✅ Manage tokens
  • ✅ Use all endpoints
CREATE TABLE zn_api_tokens (
id INT PRIMARY KEY AUTO_INCREMENT,
token VARCHAR(64) UNIQUE NOT NULL,
created_by VARCHAR(36) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP NULL,
last_used TIMESTAMP NULL,
active BOOLEAN DEFAULT TRUE
);
const axios = require('axios');
const api = axios.create({
baseURL: 'http://your-server-ip:3000/zenith/api',
headers: {
'Authorization': 'Bearer your-token-here',
'Content-Type': 'application/json'
}
});
// Get player information
async function getPlayer(player) {
try {
const response = await api.get(`/player/getinfo?name=${player}`);
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
}
}
// Ban a player
async function banPlayer(player, reason, duration) {
try {
const response = await api.post(`/ban?player=${player}?reason=${reason}&duration=${duration}`);
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
}
}
import requests
API_BASE = 'http://your-server-ip:3000/zenith/api'
HEADERS = {
'Authorization': 'Bearer your-token-here',
'Content-Type': 'application/json'
}
def get_player(player):
response = requests.get(f'{API_BASE}/player/getinfo?name={player}', headers=HEADERS)
return response.json()
def ban_player(player, reason, duration=None):
params = {'player': player, 'reason': reason}
if duration:
params['duration'] = duration
response = requests.post(f'{API_BASE}/ban', params=params, headers=HEADERS)
return response.json()

Issue: API not responding

  • Check if module is enabled
  • Verify port is not in use
  • Check firewall settings
  • Ensure server is running

Issue: Authentication failed

  • Check token validity
  • Verify token permissions
  • Check token expiration
  • Regenerate token if needed

Issue: Rate limit exceeded

  • Check rate limit settings
  • Wait for rate limit reset
  • Use whitelisted IPs
  • Increase rate limit if needed

Enable debug mode for detailed logging:

debug:
enabled: true
console: true
file: true
  • Use MySQL/MariaDB for large servers
  • Enable connection pooling
  • Monitor API usage
  • Implement caching
  • Track API usage
  • Monitor response times
  • Check error rates
  • Review rate limiting

Need help with the Web API Module? Join our Discord: https://discord.gg/2qCMn6KHj4