.api
Switch between different api modes.
Synopsis
.api [0 | 1 | 2 | off | on | json] [compact=<yes|no>]
Words without brackets are required, [ ] marks optional parts, a | b alternatives, ... a repeatable argument and [,...] a comma separated list.
Description
Selects the reply format of the Director for this console session: mode 0 or off is text for humans (the default after login), mode 1 or on is terse text for scripts without table frames and catalog notices, mode 2 or json answers every command with a JSON-RPC 2.0 object. Without an argument it acts like .api 1. The mode lasts until the next .api or the end of the session.
compact=yes after 2 or json prints the JSON on one line, any other value switches back to indented JSON; after 0 or 1 it is ignored. An unknown mode or more than two words leave the mode unchanged. In modes 1 and 2 every reply is framed by CMD_BEGIN, CMD_OK or CMD_FAILED and MAIN_PROMPT.
Over gRPC each ExecuteCommand call carries its own response_format and the Director does not remember .api; oconsole –grpc remembers the mode chosen with .api and sends it with every following command, so .api behaves as over BNET.
Arguments
| Argument | Type | Values / source | Default | Flags | Description |
|---|---|---|---|---|---|
<mode> | enum | 0, 1, 2, off, on, json | positional | API mode. | |
compact= | bool | yes, no | Compact JSON. |
Examples
Switch to JSON replies:
.api 2
JSON replies on a single line:
.api json compact=yes
Back to text mode:
.api 0