# The Lua API

Scripting Zene Studio with Lua 5.4 — what the API covers and how it is versioned.

Source: https://zenestudio.org/docs/scripting/lua-api

Markdown version of the Zene Studio page at https://zenestudio.org/docs/scripting/lua-api. For a map of the whole site, see
https://zenestudio.org/llms.txt.

---
Zene Studio embeds **Lua 5.4** and exposes a versioned API to it. If you can express a rule in Lua,
you can automate it inside the running application — without a socket, without a separate process.

## Two ways to script

| | Lua API | Control socket |
| --- | --- | --- |
| Runs | Inside the application | From another process |
| Good for | Behaviour tied to the session, custom devices, live rules | Automation, agents, tooling |
| Discoverable from | The [console](/docs/scripting/console) | `control.commands_list` |

Many things are more natural one way than the other. Use both.

## What the API covers

- project and track manipulation;
- automation, including the automation modes you can set per parameter;
- custom **script devices** — instruments and effects implemented in Lua;
- access to the same underlying operations the GUI performs.

## Script devices

A script device is a plugin whose implementation is Lua instead of C++. This is how you get a custom
instrument or effect without leaving the project: the device is defined in your project, so it travels
with it and your collaborators get it for free.

The device design has its own documented surface in the application repository, including how devices
are packaged and where they are loaded from.

## Versioning

The API is **versioned**, and it ships with a compatibility policy. That means:

- an API version is declared;
- changes within a version are additive;
- breaking changes land in a new version, with a stated migration.

This is unusual for an alpha and it is deliberate — a scripting API that changes without warning is
worse than no scripting API. See [Compatibility policy](/docs/scripting/compatibility-policy).

## Practical advice

- **Version-gate your scripts.** Check the API version at load and fail loudly if it is not what you
  expect. Otherwise it fails mysteriously on the first missing field.
- **Keep scripts in your project** where the versioning story is clear, or in version control with the
  project, so a project always comes with working scripts.
- **Learn the console first.** It is the fastest feedback loop available.

## See also

- [Console](/docs/scripting/console) — running Lua interactively.
- [Compatibility policy](/docs/scripting/compatibility-policy) — what may change.
- [Control socket](/docs/control/control-socket) — scripting from outside the process.
- [Project files and version control](/docs/files/version-control) — keeping scripts with projects.