HStats Backend is the API and ingest service for HStats.dev, a lightweight analytics platform for the Hytale modding community.
It receives anonymous server heartbeats from Hytale servers, tracks plugin usage, stores historical player/server metrics, and serves the data used by the HStats frontend, embeds, Discord tools, and developer dashboards.
- Accepts server heartbeat data for active server/player counts.
- Tracks plugin usage by private server reporting keys.
- Exposes public plugin, developer, embed, and global stats endpoints.
- Stores hourly global and plugin history.
- Supports account sessions, Discord OAuth, reCAPTCHA-protected registration, and plugin management.
- Provides Discord admin commands for maintenance, repairs, backups, and support tooling.
- Generates SVG stat cards for plugins and developer profiles.
HStats is designed to collect aggregate mod usage data, not player identity.
The backend does not collect:
- Player usernames.
- Player IP addresses.
- Player UUIDs.
- Per-player activity.
The backend does collect:
- Server UUIDs generated by reporting servers.
- Active server/player counts.
- Plugin reporting UUIDs and plugin versions.
- Operating system, Java version, CPU core count, and country-level region.
- Account data required for dashboard login and plugin ownership.
Plugins have two identifiers:
- Public plugin UUID: safe for frontend routes, public API responses, embeds, and sharing.
- Private plugin UUID: server reporting key used by Hytale servers to submit stats.
Only the private UUID should be used by a server/plugin integration. Public pages and frontend links should use public UUIDs.
- Node.js 20 or newer recommended.
- npm.
- SQLite-compatible local filesystem.
Install dependencies:
npm installCreate an environment file:
Copy-Item .env.example .envGenerate required account encryption keys:
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"Use separate generated values for:
ACCOUNT_DATA_KEYACCOUNT_DATA_HMAC_KEYACCOUNT_PASSWORD_PEPPERSESSION_SECRET
Run the backend:
node server.jsSee .env.example for all supported environment variables.
Required for normal API startup:
ACCOUNTS_DBPLUGIN_DBSERVERS_DBPLUGIN_STATS_DBSESSION_SECRETACCOUNT_DATA_KEYACCOUNT_DATA_HMAC_KEY
Required for production registration:
RECAPTCHA_SECRET_KEY
Required only when Discord features are enabled:
DISCORD_BOT_ENABLED=trueDISCORD_BOT_TOKENDISCORD_CLIENT_IDDISCORD_GUILD_ID
Optional integrations:
DISCORD_OAUTH_CLIENT_IDDISCORD_OAUTH_CLIENT_SECRETDISCORD_BACKUP_WEBHOOKSITE_LOGS_WEBHOOK
Discord bot startup is disabled by default.
To enable it:
DISCORD_BOT_ENABLED=true
DISCORD_BOT_TOKEN=...
DISCORD_CLIENT_ID=...
DISCORD_GUILD_ID=...Deploy slash commands:
node discord/deployCommands.jsSQLite database files are intentionally ignored by Git. Do not commit live .db files.
Default local database paths are:
databases/accounts.dbdatabases/plugins.dbdatabases/servers.dbdatabases/plugin_stats.dbdatabases/important_dates.dbdatabases/sessions.db
Additional API notes live in docs/:
docs/plugin-uuid-migration.mddocs/private-plugin-uuid-refresh.mddocs/embed-endpoint.mddocs/important-date-markers.mddocs/account-usernames-and-plugin-links.mddocs/discord-oauth.md
Please read SECURITY.md before deploying or reporting a vulnerability.
Do not publish:
.env- SQLite database files
- Discord webhook URLs
- Discord bot tokens
- reCAPTCHA secret keys
- account encryption keys