Skip to content
A somewhat RESTful(ish) API for Magic Mirror²
Shell JavaScript
Branch: master
Clone or download
juzim Update
Fix typo
Latest commit 7910875 Mar 10, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Mar 2, 2018
LICENSE Add license Mar 3, 2018
MMM-Api.js Check if module exists Mar 2, 2018 Update Mar 10, 2018 Added installer Mar 2, 2018
node_helper.js Added prefix to version Mar 3, 2018
package.json Pass on actions to modules Mar 2, 2018

Magic Mirror Module: Api

This module for the Magic Mirror² provides a somewhat RESTful(ish) API to control the behaviour of the mirror.

The code is based on the great MMM-Remote-Control module.



To send a notification to a module, just send a POST request to



curl -X POST 'http://localhost:3001/api/v1/modules/mmm-glance/glance_on?name=news&time=1000'


To send a global notification, use



curl -X POST 'http://localhost:3001/api/v1/notify/glance_on?name=news&time=1000'


The advantage of specifying a module is having some basic validation which helps with debugging and error handling.


curl -X POST 'http://localhost:3001/api/v1/modules/imaginary_module/do_stuff'

will return a 404 response with an error message:

{"success":"false","error":"Module not found"}


{"success":"false","error":"Action not found"}

Successful calls return



The payload is passed as URL parameters. These are neither validated nor do they trigger an error message for invalid or missing keys or values.



Routes request description
modules GET get a list of all installed modules and actions:
{"success": "true", "modules": {"alert": ["SHOW_ALERT","HIDE_ALERT"]}
modules/moduleName GET get a list of available actions for a module:
modules/moduleName/action POST send a notification to a module
notify/action POST send a global notification


Quick install

If you followed the default installation instructions for the Magic Mirror² project, you should be able to use the automatic installer. The following command will download the installer and execute it:

bash -c "$(curl -s"

Manual install

  1. Clone this repository in your modules folder, and install dependencies:
cd ~/MagicMirror/modules # adapt directory if you are using a different one
git clone
cd MMM-Api
npm install
  1. Add the module to your config/config.js file, if you add a position, it will display the URL to the remote on the mirror.
    module: 'MMM-Api'
  1. Add the IP addresses of devices you want to use to access the Remote Control to the ipWhiteList in your config.js.

  2. Restart your Magic Mirror² (i.e. pm2 restart mm).


Update this module by navigating into its folder on the command line and using git pull:

cd ~/MagicMirror/modules/MMM-Api # adapt directory if you are using a different one
git pull
npm install # install (new) dependencies

Alternatively you can run the script again:


Known limitations

  • the list of actions is generated by pulling some assumed action names from the files and should not be relied on
  • in addition the validation of modules and actions is purely cosmetic to help with debugging and error handling. Since every notification can be send with the notify command, it should not be seen as a security layer


  • Return available actions/modules on errors
  • Extract routes to separate files
  • Look for available actions only in notificationReceived block
  • (maybe) create a convention for modules to provide information about expected actions and payloads and raise errors for missing, invalid or extra data
You can’t perform that action at this time.