Getting the Server Status

The main servers we wanted to show status for are Minecraft Realms servers. They have a pretty nice API available with an endpoint that seemed to have everything we need. So we could log in, get a list of realms we have access to, and then see who is playing on what server. However, as with every API the most complicated part is authentication (why why why). The list of complications included properly formatting auth headers, two different account names (mojang and minecraft username), UUIDs, and so on. You can skip all that junk and use our code (linked at the bottom). Once we got it all figured out, reading the JSON response to the /worlds endpoint was pretty simple and we started getting data for all our servers.

Unfortunately, it seems like the part of the API response where it tells you who's logged into the server is broken and always returns null, so we needed another option. After trying a bunch of different ideas, what we ended up doing was using the Realms API to get the server IP address then using the mcstatus library to query the list of players. One further problem was that the address of a Realms server changes surprisingly often, so we need to look up the server address every time we're going to query status. Remember those innocent times when this was going to be a super simple single API call? Oh well.