{"id":414,"date":"2024-06-23T09:34:17","date_gmt":"2024-06-23T08:34:17","guid":{"rendered":"https:\/\/www.bolukan.nl\/?p=414"},"modified":"2024-06-23T10:37:23","modified_gmt":"2024-06-23T09:37:23","slug":"synology-calendar-api-v5","status":"publish","type":"post","link":"https:\/\/www.bolukan.nl\/?p=414","title":{"rendered":"Synology Calendar API v5"},"content":{"rendered":"\n<p>Synology has not yet published any documentation about the Calendar API v5. There is also little information available on forums. I have found that the network traffic of the Synology Calendar App gives me the information to use the API myself. In this article I explain how to fill your calendar from Node-red using version 5 of the API.<\/p>\n\n\n\n<p>An important change is the format of certain data in the request. Text fields must be surrounded by double-quotes in the request. So<br><code>   summary: summary,<\/code><br>has to become<br><code>   summary: `\"${summary}\"`<\/code>,<\/p>\n\n\n\n<p>Time fields are changed from text to unix timestamps numbers. So<br> <code>  dtstart: \"2025-01-01T00:00:00\",<\/code><br>has to become<br><code>   dtstart: 1735689600,<\/code><br>and in a response the API also sends a string, in this example a date for an all day event:<br><code>   dtstart_string: \"20250101\"<\/code><\/p>\n\n\n\n<p>And empty strings and empty arrays have to be send as &#8216;&#8221;&#8221;&#8216;, respectively &#8216;[]&#8217;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code> \u00a0 color: `\"\"`,<\/code><code>   participant: \"&#91;]\",<\/code><\/code><\/pre>\n\n\n\n<p>To add an event you&#8217;ll need the following steps:<br>Authenticate and get the token\/security identifier:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>https:\/\/mysynology\/webapi\/auth.cgi?api=SYNO.API.Auth&amp;version=7&amp;method=login&amp;account=myaccount&amp;passwd=mypassword&amp;session=mysessionname&amp;format=sid&amp;enable_syno_token=yes<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>flow.set(\"sid\", msg.payload.data.sid);\nflow.set(\"synotoken\", msg.payload.data.synotoken);\nflow.set(\"device_id\", msg.payload.data.device_id);<\/code><\/pre>\n\n\n\n<p>Retrieve a list of calendars, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msg.payload &nbsp;= {\n  api: \"SYNO.Cal.Cal\",\n  version: 5,\n  method: \"list\",\n  cal_type: `\"event\"`\n};<\/code><\/pre>\n\n\n\n<p>Create an all day event with dtstart as date object, to return a timestamp like 1735689600:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var event = {\n   api: \"SYNO.Cal.Event\",\n   method: \"create\",\n   version: 5,\n   cal_id: `\"${cal_id}\"`,\n   original_cal_id: `\"${cal_id}\"`,\n   summary: `\"${summary}\"`,\n   is_all_day: true,\n   tz_id: `\"\"`,\n   dtstart: Math.floor(dtstart.getTime()\/1000),\n   dtend: Math.floor(dtend.getTime()\/1000),\n   is_repeat_evt: false,\n   color: `\"\"`,\n   description: `\"\"`,\n   participant: \"&#91;]\",\n   notify_setting: \"&#91;]\",\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Synology has not yet published any documentation about the Calendar API v5. There is also little information available on forums. I have found that the network traffic of the Synology Calendar App gives me the information to use the API myself. In this article I explain how to fill your calendar from Node-red using version [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[29,14],"class_list":["post-414","post","type-post","status-publish","format-standard","hentry","category-software","tag-node-red","tag-synology"],"_links":{"self":[{"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/posts\/414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=414"}],"version-history":[{"count":4,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/posts\/414\/revisions"}],"predecessor-version":[{"id":419,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/posts\/414\/revisions\/419"}],"wp:attachment":[{"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}