Star Defenders 2D

Game Servers

Counts are updated every 60 seconds. Red servers are offline.

Server Uptime API documentation

On this website I am providing a very simple and straightforward server uptime/downtime and current playercount REST API. It responds with JSON, and is available live without a key at https://stardefenders.io:3122/ Currently, it must be requested through https.

"https://prosuwanted.ru:3000":{"playersOnServer":0,"playersOnline":0,"lastOnlineTimestamp":null,"lastOfflineTimestamp":"2024-02-11T19:34:03.548Z","isConnected":false}

The API responds with a JSON object filled with servers like this. Structured like so:

"serverLink":{
"playersOnServer":0, //Shows players in Lobby
"playersOnline":0, //Shows players in-game
"lastOnlineTimestamp":null, //Shows null if server has never been Online, otherwise a date object of when it was first recorded online.
"lastOfflineTimestamp":"2024-02-11T19:34:03.548Z", //Shows null if server has never been offline. Otherwise, a date object of when it was first recorded offline.
"isConnected":false //false if server is offline, true if server is online.
}
This API only updates every 60 seconds. There is no reason to request it more often than that on an interval. The following is the javascript used to fill the Server List bar on the left of the screen. I may also provide a discord bot embed usage later.

                document.addEventListener('DOMContentLoaded', function () {
                    fetch('https://stardefenders.io:3122/')
                        .then(response => response.json())
                        .then(data => {
                            const gameServers = document.getElementById('gameServers');
                
                            for (const serverUrl in data) {
                                const serverInfo = data[serverUrl];
                                const serverContainer = document.createElement('div');
                                const serverLink = document.createElement('a');
                                const serverDetails = document.createElement('p');
                
                                serverLink.href = serverUrl;
                                serverLink.textContent = serverUrl;
                                serverLink.style.color = serverInfo.isConnected ? '#00ff00' : '#ff0000'; // Green if connected, red if not connected
                
                                serverDetails.textContent = `Players in Lobby: ${serverInfo.playersOnServer}, Players in-game: ${serverInfo.playersOnline}`;
                
                                serverContainer.appendChild(serverLink);
                                serverContainer.appendChild(serverDetails);
                
                                gameServers.appendChild(serverContainer);
                            }
                        })
                        .catch(error => console.error('Error fetching game server data:', error));
                    })