Eranio
Color theme

Chat

Base: /api/chat

The chat section has two jobs. With GET you read the event log of the server, mainly player chat but also joins, leaves, broadcasts and permission changes. With POST you send a broadcast message to all players. This lets you build, for example, a chat mirror to Discord, a notice when someone joins, or an announcement from your panel. Everything the mod records is stored as a text file per event type, there is no database.

Handler: ChatHandler
GET /api/chat

Get chat and events

Returns the latest entries of an event log as a list of JSON objects, oldest first. The default is playerChat. Other event types the mod writes: playerJoin, playerLeave, broadcast, groupPermissionChange and playerPermissionChange. Every entry contains timestamp (ISO time with time zone), server and, depending on the type, player, message, group, action or permissions.

Parameters

Name Type Required Description
limit integer No Number of entries, default 50
eventType string No Event log to read (letters, digits, _), default playerChat

Response Example

[
  {
    "server": "main",
    "player": "Steve",
    "message": "hello"
  }
]

cURL

curl -X GET 'http://localhost:5550/api/chat?limit=20&eventType=playerChat' \
  -H 'X-Admin-Token: YOUR_TOKEN'
limit is the number of entries you want and defaults to 50, and a value that is not a number is ignored. eventType may only contain letters, digits and underscores, otherwise you get 400 with {"error": "Invalid eventType"}. If the log does not exist yet, you get an empty list with 200. Lines that are not valid JSON are skipped. For chat, join and leave, server is always "main". Only events the mod has recorded since its installation appear. For a live display, poll the endpoint regularly and remember the last timestamp.

Internal Behavior

Reads the file Events/{eventType}.log in the data folder of the mod (mods/Eranio_HytaleAdminAPI). Every line is a JSON object. The mod listens to the chat, join, leave and permission events of Hytale for this. The file is read completely on every request and only then cut down to the last limit entries, so very large logs take longer to fetch.
POST /api/chat/broadcast

Broadcast message

Sends a message to all online players. The text is sent with the prefix [Server]. The response contains success: true if the server accepted the message.

Request Body

Field Type Required Description
message string Yes Text, sent with the prefix [Server]

Response Example

{
  "success": true
}

cURL

curl -X POST 'http://localhost:5550/api/chat/broadcast' \
  -H 'X-Admin-Token: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"message": "Restart in 5 minutes"}'
The field message is required, and if it is missing the endpoint answers 400 with {"error": "Missing required field: message"}. The message is also recorded with the sender [BROADCAST] in the chat history and in the event logs broadcast and playerChat, so that it shows up later in the chat query. If the server could not send the message, the response contains success: false, and the log entry is still written.

Internal Behavior

Sends via the universe and logs it to the broadcast and playerChat event logs.