Toontown Realms - External App Access Control

Toontown Realms features a system which allows server hosts to link some functionality from their servers to their own web panels, or other external apps.

This functionality is possible due to two .json files found in the config/ directory of your server.

  • online_players.json
    • This file is written to by the server every second with player information.
  • web_commands.json
    • This file is read by the server every second and processes that information. after it is read, it is reset to an empty array []

Online Players (online_players.json)

Every second, the Toontown Realms server software writes information about all players to this JSON file The JSON file is structured as an Array of type Player as defined below The following code is represented in C# as used in an ASP.NET application

public class Player
{
	public long DoId { get; set; }  // The Player Toon's Unique ID
	public string ToonName { get; set; }
	public long AccountId { get; set; }  // The Unique ID of the player's account
	public int AccessLevel { get; set; } 
	public int ZoneId { get; set; }  // Player's current location
}

Example output of online_players.json

[
	{
		"DoId": 100040024,
		"ToonName": "Flippy Junior",
		"AccountId": 100040022,
		"AccessLevel": 100,
		"ZoneId": 2102
	},	
	{
		"DoId": 100020006,
		"ToonName": "HOSTER Flippy",
		"AccountId": 100020003,
		"AccessLevel": 800,
		"ZoneId": 61001
	}
]

You can process this information through your application for your purpose.


App Commands (web_commands.json)

Every second, the Toontown Realms server software reads this file and runs any AppCommands in it. After it is read, it is then cleared back to an empty Array.

In your application, you can "send" AppCommands (as defined below) to the server by adding them to the Array. The following code is represented in C# as used in an ASP.NET application

public class AppCommand
{
	// This will be the Command Name
	public string Command { get; set; }
	// This is a dict of the args, keyed by a string, 
	// but the value can be multiple different types depending on what command you are using.
	public Dictionary<string, object> Args { get; set; } = new();
}

Example input of web_commands.json

[
	{
		"Command": "Ban",
		"Args": {
			"DoId": 100040024,
			"Reason": "You are being banned for one week for violating rule 3",
			"Minutes": 10080
		}
	}
]

Valid App Commands

Currently, these are the available commands in game This list is subject to change at any point

"Ban"

Args:
long DoId  // Toon's UNIQUE ID
string Reason // Custom text reason to show to the player
int Minutes  // How long to ban the user for, in minutes. (0 for forever)

"Kick"

Args:
long DoId
string Reason

"Whisper"

Args:
long DoId
string Message

"Announce"

Sends a popup annoucement on the top of all players screens prefixed with Announcement:

Args:
string Message

"System"

Sends a System message to all players prefixed with Toon HQ:

Args:
string Message
An unhandled exception has occurred. See browser dev tools for details. Reload 🗙