This repository contains the server-side code for the X-Minecraft Launcher (XMCL) web API. It provides various backend services that support the launcher functionality.
The XMCL Web API serves multiple functions:
- Provides launcher update notifications and release information
- Manages real-time communication for multiplayer sessions
- Handles translations for mod descriptions and UI elements
- Offers WebRTC services for peer-to-peer connections
- Supports authentication with various services
The API is implemented in multiple ways to ensure global availability and reliability:
-
Primary Service (Deno) - Hosted on Deno Deploy
- Entry point:
index.ts - Global availability outside mainland China
- Uses MongoDB for data storage
- Entry point:
-
Backup Service (Azure Functions) - Written in TypeScript
- Entry point:
azure/index.ts - Uses the Azure Functions JavaScript/TypeScript runtime
- Provides fallback capabilities if the primary service is unavailable
- Entry point:
-
Alibaba Cloud Function Service (Deno) - Uses compiled binary
- Entry point: Compiled Deno binary via
aliyun/bootstrap - Alternative deployment option for better access in mainland China
- Uses
deno compileto create a standalone executable
- Entry point: Compiled Deno binary via
-
Mainland China Service - Specialized version in Go
- Entry point:
main.go - Optimized for access within mainland China
- Contains adaptations for the Chinese network environment
- Entry point:
/latest- Provides information about the latest launcher releases/releases/:filename- Access to launcher release files with redirection to GitHub/notifications- System notifications for launcher users from GitHub issues/flights- Feature flight information for gradual rollouts/translation- Translation services for mod descriptions (Modrinth and CurseForge)/group/:id- Real-time WebSocket communication for launcher user groups/rtc/official- WebRTC signaling for peer connections/zulu- Custom endpoint for specific launcher functionality/elyby/authlib- Authentication library access/modrinth/auth- Modrinth authentication integration/kook-badge- Access to KOOK integration information
/latest- Similar to Deno service, provides launcher release information/notifications- Provides notifications from GitHub issues/flights- Feature flight configuration/zulu- Proxies to xmcl-static-resource repository/appx- Handles Windows appx file distribution with proxy support for Chinese users
/group/:id- Real-time WebSocket communication for groups/translation- Translation services for mod descriptions/rtc/official- WebRTC signaling service
MONGO_CONNECION_STRING- Alternative name for MongoDB connection stringMONGODB_NAME- Database name (default: "xmcl-api")GITHUB_PAT- GitHub Personal Access Token for API accessOPENAI_API_KEY- API key for translation services using DeepSeek APIRTC_SECRET- Secret for WebRTC servicesCURSEFORGE_KEY- API key for CurseForge integrationMODRINTH_SECRET- Secret for Modrinth authentication integrationTURNS- TURN server configuration (format: "realm:ip,realm:ip")
GITHUB_PAT- GitHub Personal Access Token for API accessFUNCTIONS_CUSTOMHANDLER_PORT- Port for Azure Functions custom handler (legacy)
MONGO_CONNECION_STRING- MongoDB connection stringMONGODB_NAME- Database name (default: "xmcl-api")CURSEFORGE_KEY- API key for CurseForge integrationRTC_SECRET- Secret for WebRTC servicesTURNS- TURN server configuration (format: "realm:ip,realm:ip")
- Deno for the primary service
- Go for the Azure Functions and China service
- MongoDB for data storage
- Azure Functions Core Tools (for local Azure Functions testing)
# Run the Deno service locally
deno run --allow-net --allow-read --allow-env index.ts
# Build and run the Go service for China
go build main.go
./main
# Run the Azure Functions service locally
deno run build:fn
func startThe primary service is deployed on Deno Deploy, which automatically deploys from the main branch.
For Azure Functions deployment, use the Azure CLI or Azure Portal:
az functionapp deployment source config-zip -g myResourceGroup -n myFunctionApp --src ./azure.zipThe Deno service can be deployed to Alibaba Cloud Function using Serverless Devs with a compiled binary:
# Install Serverless Devs CLI
npm install -g @serverless-devs/s
# Configure your Alibaba Cloud credentials
s config add
# Compile the Deno application
deno compile --allow-net --allow-read --allow-env \
--output aliyun/xmcl-api \
index.ts
# Deploy the function
s deploy --use-local -yThe deployment uses a compiled Deno binary and automatically deploys from the main branch via GitHub Actions.
Required Secrets for GitHub Actions:
ALIYUN_ACCOUNT_ID- Alibaba Cloud Account IDALIYUN_ACCESS_KEY_ID- Alibaba Cloud Access Key IDALIYUN_ACCESS_KEY_SECRET- Alibaba Cloud Access Key Secret- Environment variables (same as Primary Service)
For the China service, deploy to a suitable hosting provider with Go support:
go build -o server main.go
# Then deploy the binary to your serverFor WebRTC functionality, a COTURN server is used. Configuration details are in COTURN.md.
This project is licensed under the MIT License - see the LICENSE file for details.