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 three different 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:
-
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)PORT
- Fallback port if Azure Functions port is not set (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")PORT
- Server port (default: "8080")
- 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 start
The 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.zip
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 server
For 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.