Skip to content

Commit fb20bd4

Browse files
committed
Merge branch 'develop' into main
2 parents c8d922d + 57b485b commit fb20bd4

26 files changed

+544
-485
lines changed

.github/ISSUE_TEMPLATE/Bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ body:
3131
required: true
3232
- type: input
3333
attributes:
34-
label: MagicMirror Version
34+
label: MagicMirror² Version
3535
description: |
3636
example:
3737
- MM: 2.16.0

API/README.md

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
## MagicMirror Remote Control API
1+
# MagicMirror² Remote Control API
22

33
## Introduction
44

5-
The MMM-Remote-Control Module for MagicMirror² implements a RESTful(-ish) API to control the Magic Mirror using the existing functionality built-in to MMM-Remote-Control, as well as the notifications commands built into most modules. In addition, the API creates a basic framework which allows for each module to expand or customize their own API by a simple notificiation.
5+
The MMM-Remote-Control Module for MagicMirror² implements a RESTful(-ish) API to control the MagicMirror² using the existing functionality built-in to MMM-Remote-Control, as well as the notifications commands built into most modules. In addition, the API creates a basic framework which allows for each module to expand or customize their own API by a simple notificiation.
66

77
This expansion was developed by [shbatm](https://github.com/shbatm) using [juzim's MMM-Api](https://github.com/juzim/MMM-Api) and of-course, [jopyth's MMM-Remote-Control](https://github.com/jopyth/MMM-Remote-Control).
88

@@ -17,30 +17,30 @@ All URLs will be of the form: `http://magicmirrorip:8080/api/{your command}` and
1717
### Basic examples for showing an Alert on the screen
1818

1919
```bash
20-
$ curl -X GET http://magicmirrorip:8080/api/module/alert/showalert?message=Hello&timer=2000
20+
curl -X GET http://magicmirrorip:8080/api/module/alert/showalert?message=Hello&timer=2000
2121
```
2222

2323
```bash
2424
$ curl -X POST http://magicmirrorip:8080/api/module/alert/showalert \
2525
-H 'content-type: application/json' \
26-
-d '{
27-
"title": "Hello World!",
28-
"message": "Alert Successfully Shown!",
26+
-d '{
27+
"title": "Hello World!",
28+
"message": "Alert Successfully Shown!",
2929
"timer": 2000
3030
}'
3131
```
3232

3333
### Basic examples of sending a Module Notification
3434

3535
```bash
36-
$ curl -X GET http://magicmirrorip:8080/api/notification/HELLO_WORLD
36+
curl -X GET http://magicmirrorip:8080/api/notification/HELLO_WORLD
3737
```
3838

3939
```bash
4040
$ curl -X POST http://magicmirrorip:8080/api/notification/HELLO_WORLD \
4141
-H 'content-type: application/json' \
42-
-d '{
43-
"mypayload": "Hello World!",
42+
-d '{
43+
"mypayload": "Hello World!",
4444
"somthingelse": "Wooo!"
4545
}'
4646
```
@@ -52,6 +52,7 @@ Providing an API key is recommended; however, remains optional. If you wish to u
5252
If you ran the `installer.sh` script when you installed the module, a non-canoical UUID is generated for you to use; you can use this unique code, or use any string you wish.
5353

5454
### Example Config Section
55+
5556
```js
5657
{
5758
module: 'MMM-Remote-Control'
@@ -64,25 +65,28 @@ If you ran the `installer.sh` script when you installed the module, a non-canoic
6465
### Passing your API key
6566

6667
The API Key can be passed in one of two ways, either as part of the query string at the end of the URL:
68+
6769
```bash
68-
$ curl -X GET http://magicmirrorip:8080/api/module/alert/showalert?message=Hello&timer=2000&apiKey=bc2e979db92f4741afad01d5d18eb8e2
70+
curl -X GET http://magicmirrorip:8080/api/module/alert/showalert?message=Hello&timer=2000&apiKey=bc2e979db92f4741afad01d5d18eb8e2
6971
```
7072

7173
It can also be passed as an Authorization Header:
74+
7275
```bash
7376
$ curl -X POST http://magicmirrorip:8080/api/module/alert/showalert \
7477
-H 'content-type: application/json' \
7578
-H 'Authorization: apiKey bc2e979db92f4741afad01d5d18eb8e2' \
76-
-d '{
77-
"title": "Hello World!",
78-
"message": "Alert Successfully Shown!",
79+
-d '{
80+
"title": "Hello World!",
81+
"message": "Alert Successfully Shown!",
7982
"timer": 2000
8083
}'
8184
```
8285

8386
***For convenience, the remainder of the examples omit the API Key***
8487

8588
## Secure Endpoints
89+
8690
Since 2.2.0, and in a way to prevent malicious actions on your mirror, a new config was added. This config allow you to, in case you don't use an apikey or never use the API at all, prevent some endpoints to work without an apikey.
8791
As usual, this option can be disabled, but this will expose your Mirror to potentials hackers, so it's up to you to turn it off.
8892

@@ -105,7 +109,7 @@ There are three general categories of API commands:
105109
**1. MMM-Remote-Control Internal Commands** -- these are used to call the existing commands that MMM-Remote-Control already exposes. For example, to turn off the monitor ("MONITOROFF"):
106110

107111
```bash
108-
$ curl -X GET http://magicmirrorip:8080/api/monitor/off
112+
curl -X GET http://magicmirrorip:8080/api/monitor/off
109113
```
110114

111115
**2. External APIs (Guessed)** -- when this module first loads, it parses all of the installed modules' source code and checks for any custom notifications that are used. From this basic search, it tries to "guess" notification actions that may be valid, without them being explicitly defined anywhere else. For example, the "alert" command examples above are not defined within this module, the 'alert' module just looks for a notification, "SHOW_ALERT"--this is exposed as a `/module/alert/showalert` action in the External API processor. Full credit to this idea goes to `juzim` from the MMM-Api module.
@@ -118,7 +122,7 @@ The majority of MMM-Remote-Control's abilities are extended to the API (this is
118122

119123
Review the API documentation online [here](https://ezeholz.github.io/MMM-Remote-Control/)
120124

121-
Or check it in your own installation using http://ip-of-your-mirror:8080/api/docs
125+
Or check it in your own installation using <http://ip-of-your-mirror:8080/api/docs>
122126

123127
### 2. External APIs (Guessed)
124128

@@ -131,13 +135,13 @@ As discussed above, these methods are guessed based on your currently installed
131135

132136
- *NOTE:* Just because an action appears in this list, does not necessarily mean it is valid and the related module will do what you want. Consult each modules' README for details on what notifications can be used and how.
133137

134-
#### Example:
138+
#### Example
135139

136140
```bash
137-
$ curl -X GET http://magicmirrorip:8080/api/module/newsfeed
141+
curl -X GET http://magicmirrorip:8080/api/module/newsfeed
138142
```
139143

140-
#### Returns:
144+
#### Returns
141145

142146
```json
143147
{
@@ -187,17 +191,17 @@ If correctly formated, any details sent here will override the "guessed" action
187191

188192
```js
189193
let payload = {
190-
module: this.name,
191-
path: "modulename",
192-
actions: {
193-
actionName: {
194-
method: "GET",
195-
notification: "NOTIFICATION_TO_SEND",
196-
payload: ObjectToSend,
194+
module: this.name,
195+
path: "modulename",
196+
actions: {
197+
actionName: {
198+
method: "GET",
199+
notification: "NOTIFICATION_TO_SEND",
200+
payload: ObjectToSend,
197201
prettyName: "Action Name"
198202
},
199-
anotherActionName: {
200-
method: "POST",
203+
anotherActionName: {
204+
method: "POST",
201205
notification: "NOTIFICATION_TO_SEND"
202206
}
203207
}
@@ -216,7 +220,7 @@ this.sendNotification("REGISTER_API", payload);
216220
| `prettyName` | *Optional:* You can specify a Formatted Name to use in dynamic menus, like the MMM-Remote-Control Module Control menu, otherwise one will be guessed based on the Notification text.
217221
| `payload` | *Optional:* If you always want the module to send the same `payload`, you can provide an `Object` here. It will be merged into the `payload` sent with the notification, which will also include:<br>1. URL Parameter, if used. See notes on `payload` Object below.<br>2. Query String, if used. API key will be removed.<br>3. Request body, if `POST` method is used and a body sent.<br>4. Finally, this parameter.
218222

219-
#### About the `payload` Object
223+
#### About the `payload` Object
220224

221225
Your module will be sent a `payload` with the notification, depending on the request details, and if you provided a `payload` Object to send. It is a merged object, containing one or more of the following inputs.
222226

0 commit comments

Comments
 (0)