mcapi
A unified, clean-room async Rust client for the Minecraft HTTP API ecosystem — covering Mojang / Microsoft Auth, Modrinth, CurseForge, Yggdrasil / authlib-injector, Blessing Skin / CSL, Mod Loaders, BMCLAPI, and Java Runtimes in a single feature-gated crate.
Highlights
- Modular & Feature-Gated: Enable only the platform modules and TLS backend you need via Cargo features.
- Shared
HttpClient(Arc-backed): Configure connection pooling,User-Agent, timeouts, mirror routing, and retry policies once throughMcApi(orHttpClient) and clone zero-cost across every client. - Unified Error Handling: One
#[non_exhaustive]mcapi::Errorandmcapi::Result<T>across all modules, with helpers such asstatus_code(),api_status_error(),is_not_found(), andis_rate_limited(). Public dependency crates (reqwest,url,jiff,uuid,rsa,serde_json) are re-exported undermcapi::reexportsso callers never hit version-mismatch errors. - Mirror Routing & Strict Credential Isolation: Built-in
Mirror::Bmclapi,Mirror::Mcim,Mirror::China,Mirror::Combined, andMirror::Customprefix rewriting with multi-candidate fallback to official origins. Authenticated and mutating calls (client.authed(token)) always bypass mirrors so tokens and API keys never leak to third-party hosts. - Resilient & Forward-Compatible: Parses
Retry-AfterandX-Ratelimit-*headers, supports opt-in 429/5xx/transport backoff retries with jitter, blocks HTTPS-to-HTTP redirect downgrades, uses forward-compatibleUnknownenum variants, and redacts all credentials as[REDACTED]inDebugoutput.
Installation
Add mcapi with the default feature set (full + tls-aws-lc):
[]
= "0.2"
Or pick only the modules and TLS backend you need (for example, a launcher using Mojang, Modrinth, Loaders, and Java Runtimes):
[]
= { = "0.2", = false, = ["mojang", "modrinth", "loaders", "java", "tls-aws-lc"] }
Quick Start
1. Shared McApi Entry Point
Share one reqwest::Client connection pool, mirror strategy, and retry policy across all platform clients:
use Duration;
use ;
use ;
async
2. Authenticated Operations (client.authed(token))
Public read endpoints live directly on <Platform>Client. Protected and mutating endpoints live on client.authed(token) (Authed<'_>), which sends requests directly to official origins and never routes credentials through mirrors:
use MojangClient;
async
3. Custom Mirrors & Keyless CurseForge Mirrors
Combine built-in presets or define custom URL prefix rewrites via Mirror::Custom:
use ;
async
When using a mirror that rewrites
https://api.curseforge.com(such asMirror::McimorMirror::China),api.curseforge(None)constructs a keyless mirror client (skipping officialapi.curseforge.comfallback since no key is configured). If an API key is provided viaapi.curseforge(Some(key)),x-api-keyis only attached to direct unrewritten requests targetingbase_url(including custom gateways configured viawith_base_url) and is never forwarded toMirror-rewritten hosts.
Mirror Routing
| Preset | Upstream Coverage |
|---|---|
Mirror::Official (default) |
Official upstream endpoints directly |
Mirror::Bmclapi |
Mojang Piston/Launcher/Assets/Libraries, Fabric, Quilt, Forge, NeoForge, LiteLoader, and authlib-injector via BMCLAPI |
Mirror::Mcim |
Modrinth API/CDN and CurseForge API/CDN via MCIMirror |
Mirror::China |
Zero-allocation preset combining Mirror::Bmclapi + Mirror::Mcim |
Mirror::Combined(Vec<Mirror>) |
Ordered multi-mirror fallback chain (first matching rule wins, falling through candidates on failure) |
Mirror::Custom(Vec<RewriteRule>) |
User-defined segment-boundary URL prefix rewrite rules |
Enabling ResiliencePolicy::fallback_to_official(true) automatically falls back to the official origin if a mirror candidate fails with a transport error, HTTP 404, HTTP 5xx, or malformed JSON/XML response.
Feature Flags
Platform Modules
| Feature | Default | Description |
|---|---|---|
full |
✅ | Enables all standard platform modules (curseforge, modrinth, mojang, yggdrasil, yggdrasil-authlib, blessing, loaders, bmclapi, java); excludes opt-in write/crypto/tracing features |
mojang |
via full |
Microsoft OAuth2 (Device Code + PKCE) → XBL → XSTS (XErr) → Minecraft login, UUID/session lookup, Minecraft Services, Piston Meta, Launcher Content (news.json, javaPatchNotes.json) |
modrinth |
via full |
Modrinth v2 REST API (CNF facet search, projects, versions, SHA-1/512 hash lookup & update, tags, statistics, authenticated reads) |
modrinth-write |
❌ | Opt-in Modrinth v2 creator/mutation & multipart upload APIs (create_project, create_version, team/user management, payout withdrawal; enables reqwest/multipart) |
curseforge |
via full |
CurseForge Core API v1/v2 (search, mods/files, Murmur2 fingerprint / fingerprint_file / fingerprint_reader, Minecraft versions/loaders, keyless mirror mode) |
curseforge-cdn-fallback |
❌ | Opt-in unofficial edge.forgecdn.net fallback URL synthesis (File::edge_download_url) when download_url is omitted (undocumented layout; bypasses author opt-out / ToS risk) |
yggdrasil |
via full |
Yggdrasil auth/session/profile client and ALI auto-discovery (YggdrasilClient::discover) |
yggdrasil-authlib |
via full |
authlib-injector build metadata client (AuthlibInjectorClient) |
yggdrasil-verify |
❌ | Opt-in RSA-SHA1 (SHA1withRSA) signature verification (ProfileProperty::verify_signature, GameProfile::decode_and_verify_textures) |
blessing |
via full |
Blessing Skin v6 REST API (login, skinlib, upload/manage, closet, players) + CustomSkinLoader endpoints |
loaders |
via full |
Fabric Meta v2, Quilt Meta v3, Forge (Maven XML / Promotions), NeoForge (Maven XML / 1.20.1 legacy), LiteLoader official manifest |
bmclapi |
via full |
Dedicated BmclapiClient for BMCLAPI Forge, NeoForge, LiteLoader, and OptiFine index endpoints |
java |
via full |
Mojang Official Java Runtimes (all.json + file manifests), Adoptium Temurin v3, Azul Zulu Metadata v1 |
Shared & Optional Capabilities
| Feature | Default | Description |
|---|---|---|
http |
via modules | Shared Arc-backed HttpClient, Mirror, ResiliencePolicy, McApi, and McApiBuilder |
profile |
via mojang/yggdrasil |
Shared ProfileProperty and base64 textures payload decoding |
stream |
❌ | Enables reqwest/stream (Response::bytes_stream); HttpClient::stream + Response::chunk() already work without it |
tracing |
❌ | Opt-in tracing debug/warn instrumentation for outbound requests, retries, and mirror fallback |
TLS Backends
Select one TLS backend whenever any HTTP feature is enabled:
| Feature | Default | Backing reqwest Feature |
|---|---|---|
tls-aws-lc |
✅ | reqwest/rustls (aws-lc-rs) |
tls-native |
❌ | reqwest/native-tls |
tls-native-vendored |
❌ | reqwest/native-tls-vendored |
tls-rustls-no-provider |
❌ | reqwest/rustls-no-provider (supply your own rustls crypto provider) |
MSRV
The Minimum Supported Rust Version is 1.88.0 (Rust 2024 edition), verified in CI on every push and pull request.
Contributing
- Read CONTRIBUTING.md for local setup, offline testing with
MockServer, feature-matrix verification commands, and commit conventions. - Read AGENTS.md for architecture invariants and coding conventions.
- See CHANGELOG.md for release history.
License
Dual-licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.