HomeJavaModsServerDataAPI
ServerDataAPI
ModsJava

ServerDataAPI

API plugin for accessing server and player information.

⬇ Download on Spigot
Having problems or questions? Join our discord server.
[​IMG]

ServerDataAPI is designed to provide detailed information about your Minecraft server through multiple API endpoints. This plugin allows administrators to access real-time data, such as player statistics, world information, and general server status. You can choose to store data using MySQL or SQLite, configurable in the config.yml file .

Key Features:
Installation Guide
  1. Download the plugin and place it in your plugins folder.
  2. Start the server to generate the config.yml file.
  3. Edit config.yml to configure the port, the database (MySQL or SQLite), set rate limits, and adjust other parameters.
  4. Configure API access by specifying allowed origins to control which domains or IPs can interact with the API.
  5. Restart your server, and the plugin is ready to use.
API Endpoints
(All the methods are GET)

/players
Retrieves a list of all online players, including details like their name, UUID, IP address, and health status.

/player/:name
Fetches information about a specific player (whether online or offline). If the player is online, it includes their real-time data such as health, location, experience, and level. If the player is offline, it fetches the data from the database.

/server-status
Provides the current status of the Minecraft server, including server version, the number of online players, max players allowed, whitelist status, and the server's uptime.

/whitelisted-players
Returns a list of all players who are whitelisted on the server, with their name and UUID.

/banned-players
Returns a list of all players who are banned from the server, including their name and UUID.

/worlds
Retrieves details about all loaded worlds on the server, including the world name, environment type, number of players, number of entities, and the current time in the world.

/online-player-count
Returns the total number of online players and the maximum number of players that the server can handle.


Example of use in a discord bot:
Code (Text):
const { Client, GatewayIntentBits } = require('discord.js');
const axios = require('axios');

// Your Discord bot token and API URL
const BOT_TOKEN = 'YOUR_DISCORD_BOT_TOKEN';
const API_URL = 'http://localhost:4567';  // Replace with your Minecraft API URL

const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });

client.once('ready', () => {
  console.log('Bot is online!');
});

client.on('messageCreate', async message => {
  // Ignore bot messages and only respond to "!players" command
  if (message.author.bot || message.content !== '!players') return;

  try {
    const response = await axios.get(`${API_URL}/players`);
    const players = response.data;

    if (players.length > 0) {
      message.channel.send(`Online players: ${players.map(p => p.name).join(', ')}`);
    } else {
      message.channel.send('No players are online.');
    }
  } catch (error) {
    message.channel.send('Error fetching players from the server.');
  }
});

client.login(BOT_TOKEN);
How It Works:


Thank you for using our plugin! We hope it helps enhance your Minecraft server experience. Your support means a lot to us, and we're always striving to improve. If you have any feedback, suggestions, or if you'd like a custom endpoint, feel free to contact us at our Discord. Happy gaming, and thanks again from the team at Lomihost.com!

ServerDataAPI is a free Minecraft Java mod. Compatible with Minecraft 1.20, 1.20.6, 1.21. Downloaded 248 times (via Spigot). Download it and open it directly in the game.

Explore more