# The API

> One envelope, 122 payload kinds, a local HTTP surface, and three SDKs generated from a single contract artefact.

Everything lemonfiber can tell you, it can tell a machine. Every answer arrives
in one wrapper — `api_version`, `kind`, `data` — and that wrapper is a stable,
versioned interface rather than output that happens to be parsable.

It reaches you two ways. [`--json`](/commands/global-flags/) on the command line
prints it. `lemonfiber ui` serves it over local HTTP: one read endpoint for each
question a command answers, `POST /api/actions/<name>` for anything that changes
something, and `GET /api/events` as a live stream — all of it behind a token
minted for that run, on a socket bound to this machine. `--lan` offers it to
your network instead, and is refused until a password has been set. Both
surfaces dispatch through the same entry point, so neither can say something
about your stack that the other would not.

The binary carries the web app as well, embedded the way the stack beside it is:
a submodule at `assets/web`, pinned to a built revision, and a build whose two
halves speak different wire versions stops rather than shipping. A build told to
carry none says so, and `lemonfiber ui --assets <PATH>` serves a directory
instead. The shape of the surface is
[the web API contract](https://lemonfiber.app/spec/20-architecture/contracts/web-api/);
[the envelope](/api/the-envelope/) covers the endpoints, the guard, and how a
stack says what it can do.

The three SDKs below are written against that contract and generate their types
from the same artefact the command line serialises with, so what they parse is what both
surfaces already emit.

- [The envelope](/api/the-envelope/)

  The fields every payload arrives in, and the rules a client has to keep.
- [Every payload kind](/api/kinds/)

  Every kind the contract describes, and the six documented field by field.
- [The TypeScript SDK](/api/typescript-sdk/)

  Typed calls, a typed event stream and a typed error, with no runtime dependencies.
- [The PHP SDK](/api/php-sdk/)

  A typed class for every kind, typed exceptions for every failure, built on Saloon.
- [The Python SDK](/api/python-sdk/)

  An asynchronous and a synchronous client that answer the same calls, with typed answers for every kind.
- [Home Assistant](/api/home-assistant/)

  The stack's health, downloads and disk in Home Assistant, and a few controls, through a key the operator mints.
- [AI assistants over MCP](/api/ai-assistants/)

  The MCP server the specification sets out for an assistant. It has no code yet.
- [The payload reference](/api/reference/)

  Every kind, and every type its data is built from, field by field, read from the contract artefact itself.
- [Two version numbers](/api/two-version-numbers/)

  Why the package version and the wire version are different numbers doing different jobs.

The shapes are generated and the meanings are not. Fields, types, optionality and
permitted enum values come from a contract artefact built out of the Rust types
that actually serialise the reply, so no client transcribes them by hand.
Everything a schema cannot express — the heartbeat, what a resumed stream may
claim is current, where the token travels — is prose in the contract, and every
client implements and tests it.

## Where to go next

If you are writing a script rather than a client, [the global flags](/commands/global-flags/)
covers `--json` and [the commands](/commands/) covers what you can ask for. If
you are building against the boundary itself,
[the architecture notes](https://contribute.lemonfiber.app/architecture/) explain how the core is put
together behind it.
