Skip to content
Dashboard

The Minekube API

View as Markdown

The Minekube API is one API for every network. Relays, connectors and the mk CLI all call it, and it is not in the path of a player’s bytes. Minekube runs it at api.minekube.com, during the preview at api.staging.minekube.com; mk api runs the same code on your machine, and you can host it yourself.

Its areas are paths under one host: a network’s instances, its versions and deployments, accounts, and identity, with each network’s issuer under /n/<network>.

The part of the API that knows who is who is the registry. It says which key belongs to which network and what labels and status each instance has. Around it, the API keeps which account owns a network and which version runs on which instances.

What Kept in
Every key and the network it belongs to, pending claim codes, invites and the relays One directory object
A network’s instances with their labels, load and home relay, its owner, trust rules, versions and deployments One object per network
Accounts, login codes and sessions One accounts object
The bundles of every version, by their hash Object storage, readable only by the network’s members

The API is a Cloudflare Worker, and each of these objects is a Durable Object. The directory and the network objects are the registry. A request goes from the Worker to exactly one object; no object calls another in a player’s path.

The API answers every caller according to who it is, and nobody shows a static token.

  • Instances sign each request with their key, and see only their own network.
  • Relays show a short-lived token from an issuer the API’s operators trust, and may look up routes.
  • Accounts show their session’s access token, and manage the networks they own.
  • Admins show a short-lived token from a trusted issuer, and manage every network. On Minekube’s API, that is Minekube; on an API you host yourself, it is you.
  • Anyone may read a network’s OpenID Connect discovery document and key set.

Identity and the network boundary must have one answer that every relay and instance agrees on. An API that every part trusts gives that answer. Durable Objects hold each network’s state in one place with transactions, keep the control channels of idle instances open at almost no cost, and need no servers of Minekube’s own.

When the API is unreachable, relays serve joins from the answers they cached, and every instance keeps running the bundles it already has.

What the API says to connectors and relays is declared once, as an Effect Schema. The Rust types of the connector and relay are generated from it, and CI fails if the two drift apart. The HTTP API is declared once too, and mk calls it through a client derived from that declaration.

  • Not a relay. It never carries player traffic.
  • Not a policy engine. It knows who is in which network and what labels they have. What a network does with that is the network’s code.

The API is built, runs on staging, and can run on your own Cloudflare account or locally in workerd. Production at api.minekube.com, for networks at g.minekube.net, comes next. Planned: tokens for players, a signing key of each network’s own, and hostnames and custom domains per network.

Was this helpful?