LY-SERVER(1)

πŸ“¦ version 0.9.10, in arch rolling

πŸ’… LY-SERVER(1) β€” like, the whole manual, but make it make sense

okay so first things first, the manual name is ly-server and it lives in the python-ly family (that's the manual section, bestie β€” man page LY-SERVER(1)). Here's the vibe:

NAME

ly-server β€” Manipulate LilyPond source files via HTTP

Usage:

ly-server [options]

An HTTP server for manipulating LilyPond input code ✨


πŸŽ›οΈ SERVER OPTIONS

  • -v, --version β€” show version number and exit. that's it, that's the whole job πŸ’
  • -h, --help β€” show this help text and exit
  • -p,--port PORT β€” port server listens to (default 5432)
  • -t,--timeout TIME β€” If set, server shuts down automatically after -t seconds of inactivity. NOT IMPLEMENTED YET! 😭 like, it's giving "coming soon" energy, do not rely on it

🌸 COMMAND OPTIONS

  • -e,--encoding ENC β€” (input) encoding (default UTF-8)
  • --output-encoding ENC β€” output encoding (default to input encoding)
  • -l,--language NAME β€” default pitch name language (default to "nederlands")
  • -d <variable=value> β€” set a variable (see below)

Command options define defaults for the execution of commands triggered by HTTP requests. These options can be overridden by the individual HTTP request. (yes bestie, per-request override, we love a flexible queen πŸ‘‘)


🌈 HTTP REQUESTS

GET Requests

Some GET requests will be implemented later to retrieve values or change some server settings based on the URL path. (key word: later. manifesting rn πŸ™)

POST Requests

The server accepts POST requests without (currently) making use of the URL path. As the request body it expects a single JSON string with the following elements:

  • commands (mandatory) β€” An array with one or more commands to be executed subsequently. Each entry contains:
    • command (mandatory): A name for the command. It has to be one out of the list of available commands below.
    • args (optional): If a command requires arguments (e.g. the transpose command) they are given as a single string value.
    • variables (optional): A dictionary of variable assignments. Keys have to be from the list below, and proper value types are checked. If one or more variables are given they will be set before the command is executed. A variable may be modified again before the execution of the next command but it is not reset automatically. Giving a variable with a value of '' unsets the variable. 🫢
  • options (optional) β€” A dictionary of option assignments. Keys have to be from the above list of Command Options, taking the long name without the leading hyphens, e.g. { "encoding": "UTF-16" }. If an option is given here it overrides the default option given on the command line, but only for the current command. (sneaky little per-command override, iconic)
  • data (mandatory) β€” A single string containing the LilyPond input document.

The server will try to construct a series of commands from the request, and if anything is wrong with it send a "Bad Request" message with HTTP response code 400. rude, but fair πŸ’€

πŸ“¦ Response Object

If the commands execute successfully the response body will contain a serialized JSON object with the following elements:

  • info β€” An array of entries with the result of "info" commands (see below). Each entry has a command and an info field.
  • doc β€” An object with two fields:
    • content β€” A string with the content of the document with all "edit" commands applied consecutively. (If no edit commands have been specified this contains the original input.
    • commands β€” An array with the names of the commands that have been applied.
  • exports β€” An array with entries for each applied "export" command. Each entry has the following fields:
    • doc β€” A string with the content of the converted/exported document
    • command β€” The name of the applied command

🧚 Commands

There are three types of commands whose results are handled independently:

  • "info" commands retrieve metadata from the input document
  • "edit" commands modify the document, subsequent edit commands cascade the modifications
  • "export" commands that convert the input to another format. Subsequent commands are not affected by the result of export commands.

Informative commands that return information and do not change the file:

  • mode β€” print the mode (guessing if not given) of the document
  • version β€” print the LilyPond version, if set in the document
  • language β€” print the pitch name language, if set in the document

Commands that modify the input:

  • indent β€” re-indent the file
  • reformat β€” reformat the file
  • translate <language> β€” translate the pitch names to the language
  • transpose <from> <to> β€” transpose the file like LilyPond would do, pitches are given in the 'nederlands' language
  • abs2rel β€” convert absolute music to relative
  • rel2abs β€” convert relative music to absolute

Commands that convert the input to another format:

  • musicxml β€” convert to MusicXML (in development, far from complete) β€” girl it's a work in progress, don't come for her 😭
  • highlight β€” export the document as syntax colored HTML

πŸ“ Variables

The following variables can be set to influence the behaviour of commands. If there is a default value, it is written between brackets:

  • mode β€” mode of the input to read (default automatic) can be one of: lilypond, scheme, latex, html, docbook, texinfo.
  • encoding [UTF-8] β€” encoding to read (also set by -e argument)
  • default-language [nederlands] β€” the pitch names language to use by default, when not specified otherwise in the document
  • output-encoding β€” encoding to write (defaults to encoding, also set by the --output-encoding argument)
  • indent-tabs [false] β€” whether to use tabs for indent
  • indent-width [2] β€” how many spaces for each indent level (if not using tabs)
  • full-html [True] β€” if set to True a full document with syntax-highlighted HTML will be exported, otherwise only the bare content wrapped in an element configured by the wrapper- variables.
  • stylesheet β€” filename to reference as an external stylesheet for syntax-highlighted HTML. This filename is literally used in the <link rel="stylesheet"> tag.
  • inline-style [false] β€” whether to use inline style attributes for syntax-highlighted HTML. By default a css stylesheet is embedded.
  • number-lines [false] β€” whether to add line numbers when creating syntax-highlighted HTML.
  • wrapper-tag [pre] β€” which tag syntax highlighted HTML will be wrapped in. Possible values: div, pre, id and code
  • wrapper-attribute [class] β€” attribute used for the wrapper tag. Possible values: id and class.
  • document-id [lilypond] β€” name applied to the wrapper-attribute. If the three last options use their default settings the highlighted HTML elements are wrapped in an element <pre class="lilypond"></pre>
  • linenumbers-id [linenumbers] β€” if linenumbers are exported this is the name used for the <td> elements

✨ EXAMPLES

Here is the basic invocation, listening on port 5432:

ly-server

Specifying port and a timeout:

ly-server -p 4000 -t 5000

πŸ“¨ Sample Requests

The simplest request, just applying one edit command. In this case the result will be in result['doc']['content']:

{
    'commands': [
        {
            'command': 'indent'
        }
    ],
    'data' : "\relative c' { c ( d e f ) }"
}

Another simple request, this time applying an "info" command. The result will be in result['info'], containing lilypond in the info field and mode in the command field:

{
    'commands': [
        {
            'command': 'mode'
        }
    ],
    'data' : "\relative c' { c ( d e f ) }"
}

And a more complex example. This will first transpose the document and then convert the transposed version independently to highlighted HTML and MusicXML. Additionally it will retrieve the mode. This time the result will be in all three places: the transposed document in doc.content, the mode in info.info, and HTML and MusicXML in exports[0].doc and exports[1].doc.:

{
    'commands': [
        {
            'command': 'transpose',
            'args': 'c d'
        },
        {
            'command': 'highlight',
            'variables': { 'full-html': 'false' }
        },
        { 'command': 'musicxml' },
        { 'command': 'mode' },
    ],
    'options': {
        'language': "deutsch"
    },
    'data': "\relative c' { c4 ( d e ) }"
}

🫢 Author

Wilbert Berendsen

2025, Wilbert Berendsen


and that's the whole page bestie!! πŸŽ€ this was version 0.9.10, dated Apr 04, 2026, served fresh from the python-ly kitchen β€” go forth and manipulate some LilyPond, you absolute icon πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from