Synadm CLI Package

The synadm.cli package contains all the command line frontend code (using the Python Click module), see the sections for each subcommand for help on usage and have a look into the files inside the synadm/cli directory to see how the CLI frontend is constructed. The main command is defined in and each subcommand lives in its own module (e.g,, …)

Click command definition code is not very well suited for autogenerated Python package documentations (in this case using Sphinx autodoc) but one thing in this package that is worth mentioning and generating documentation for, is the synadm.cli.APIHelper class which is the connection between the CLI code and the backend code in synadm.api:

CLI base functions and settings

class synadm.cli.APIHelper(config_path, verbose, batch, output_format_cli)

Bases: object

API client enriched with CLI-level functions, used as a proxy to the client object.

FORMATTERS = {'human': <function humanize>, 'json': <function dumps>, 'pprint': <function pformat>, 'yaml': <function dump>}
CONFIG = {'admin_path': '/_synapse/admin', 'base_url': 'http://localhost:8008', 'homeserver': 'auto-retrieval', 'matrix_path': '/_matrix', 'server_discovery': 'well-known', 'timeout': 30, 'token': '', 'user': ''}

Log both to console (defaults to WARNING) and file (DEBUG).


Load the configuration and initialize the client.


Write a new version of the configuration to file.


Output data object using the configured formatter.


Try to retrieve the homeserver name.

When homeserver is set in the config already, it’s just returned and nothing is tried to be fetched automatically. If not, either the location of the Federation API is looked up via a .well-known resource or a DNS SRV lookup. This depends on the server_discovery setting in the config. Finally the Federation API is used to retrieve the homeserver name.


uri (string) – proto://name:port or proto://fqdn:port


hostname, FQDN or DOMAIN; or None on errors.

Return type



Checks whether the given user ID is an MXID already or else generates it from the passed string and the homeserver name fetched via the retrieve_homeserver_name method.


user_id (string) – User ID given by user as command argument.


the fully qualified Matrix User ID (MXID) or None if the

user_id parameter is None.

Return type