Synology Calendar API - List calendars

This is an example how to list all the available calendars on your synology using the SYNO.Cal.Cal API version 5. Please look at the flow Synology API Auth login to authentificate the user to be authorised to run this flow.
Check the Synology API Collection for related examples.

[{"id":"70cfcd28d32bcc90","type":"group","z":"55979001e6fb4b69","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["92a3aad42c1ef629","baeb98c0b6f3a029","5a1e13fda682647f","e54c7a15f4730ab1","4e2b58b26528a699","621ab49ab08d1348"],"x":34,"y":39,"w":1032,"h":142},{"id":"92a3aad42c1ef629","type":"http request","z":"55979001e6fb4b69","g":"70cfcd28d32bcc90","name":"","method":"use","ret":"obj","paytoqs":"query","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":550,"y":140,"wires":[["4e2b58b26528a699"]]},{"id":"baeb98c0b6f3a029","type":"inject","z":"55979001e6fb4b69","g":"70cfcd28d32bcc90","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":140,"wires":[["e54c7a15f4730ab1"]]},{"id":"5a1e13fda682647f","type":"debug","z":"55979001e6fb4b69","g":"70cfcd28d32bcc90","name":"reponse","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":960,"y":140,"wires":[]},{"id":"e54c7a15f4730ab1","type":"function","z":"55979001e6fb4b69","g":"70cfcd28d32bcc90","name":"SYNO.Cal.Cal/list","func":"msg.method = \"GET\";\nmsg.url = flow.get(\"synoentryurl\");\nmsg.cookies = { id: flow.get(\"sid\") };\nmsg.headers = { 'X-SYNO-TOKEN': flow.get(\"synotoken\") };\n\n// Set the query parameters\nmsg.payload  = {\n    api: \"SYNO.Cal.Cal\",\n    version: 5,\n    method: \"list\",\n    cal_type: `\"event\"`\n};\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":140,"wires":[["92a3aad42c1ef629"]]},{"id":"4e2b58b26528a699","type":"function","z":"55979001e6fb4b69","g":"70cfcd28d32bcc90","name":"save calendars","func":"node.status({\n    fill: (msg.payload.data.list.length != 0) ? \"green\" : \"red\",\n    shape: \"ring\",\n    text: \"# calendars: \" + msg.payload.data.list.length\n}); \n\nvar calendars = [];\n\nmsg.payload.data.list.map(cal => {\n    calendars.push({\n        cal_displayname: cal.cal_displayname,\n        cal_color: cal.cal_color,\n        cal_id: cal.cal_id,\n        original_cal_id: cal.original_cal_id\n    });\n    flow.set(cal.cal_displayname.replace(/\\s+/g, '_'), cal.cal_id);\n});\n\nflow.set(\"calendars\", calendars);\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":140,"wires":[["5a1e13fda682647f"]]},{"id":"621ab49ab08d1348","type":"comment","z":"55979001e6fb4b69","g":"70cfcd28d32bcc90","name":"List all available calendars","info":"","x":170,"y":80,"wires":[]}]

Flow Info

Created 1 year, 1 month ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • comment (x1)
  • debug (x1)
  • function (x2)
  • http request (x1)
  • inject (x1)
Other

Tags

  • Synology
  • API
  • SYNO.Cal.Cal
  • Calendar
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option