{"id":1112,"date":"2021-11-01T20:50:31","date_gmt":"2021-11-02T01:50:31","guid":{"rendered":"https:\/\/docs.joedolson.com\/my-calendar\/?p=1112"},"modified":"2025-12-23T16:06:51","modified_gmt":"2025-12-23T22:06:51","slug":"my-calendar-api","status":"publish","type":"post","link":"https:\/\/docs.joedolson.com\/my-calendar\/my-calendar-api\/","title":{"rendered":"My Calendar &#8211; API"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The My Calendar exports API is enabled at <code>My Calendar > Settings > General<\/code>. This API allows you to generate a CSV, JSON, or iCal formatted export of My Calendar event data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"687\" height=\"540\" src=\"https:\/\/docs.joedolson.com\/my-calendar\/wp-content\/uploads\/sites\/3\/2021\/11\/image.png\" alt=\"Screenshot of the My Calendar General settings, including the API configuration.\" class=\"wp-image-1477\" srcset=\"https:\/\/docs.joedolson.com\/my-calendar\/wp-content\/uploads\/sites\/3\/2021\/11\/image.png 687w, https:\/\/docs.joedolson.com\/my-calendar\/wp-content\/uploads\/sites\/3\/2021\/11\/image-300x236.png 300w\" sizes=\"auto, (max-width: 687px) 100vw, 687px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The API is not enabled by default. Once enabled, you can access it using URL parameters on your site:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;www.example.com\/?my-calendar-api=json&amp;from=2021-02-01&amp;to=2022-01-31<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>my-calendar-api<\/code> parameter is used to set the export format, and accepts <code>json<\/code>, <code>csv<\/code>, and <code>ical<\/code> as options.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"parameters\">Parameters<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>my-calendar-api<\/code>: format to return, \u2018json\u2019, \u2018csv\u2019, \u2018ical\u2019<\/li>\n\n\n\n<li><code>from<\/code>: starting date to retrieve, YYYY-MM-DD (default: current date.)<\/li>\n\n\n\n<li><code>to<\/code>: end date to retrieve, YYYY-MM-DD (default: 7 days from today.)<\/li>\n\n\n\n<li><code>mcat<\/code>: Category ID to limit by.<\/li>\n\n\n\n<li><code>ltype<\/code>: Location type to restrict to (keywords: &#8216;name&#8217;, &#8216;city&#8217;, &#8216;state&#8217;, &#8216;zip&#8217;, &#8216;country&#8217;, &#8216;region&#8217;)<\/li>\n\n\n\n<li><code>lvalue<\/code>: Location value to match against location field type<\/li>\n\n\n\n<li><code>author<\/code>: Events by author ID<\/li>\n\n\n\n<li><code>host<\/code>: Events by host ID.<\/li>\n\n\n\n<li><code>search<\/code>: text search query terms.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Private events and drafts are automatically excluded from exports. However, you can set an authentication key to allow authenticated access to the export that includes private events and drafts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once enabled, the export API is available to the public by default. You can restrict access to the API using your own program logic using the filter <code>mc_api_key<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * Check for and validate access to the My Calendar exports API.\n *\n * @return bool False to block; true to allow.\n *\/\nfunction your_api_key() {\n\t$valid = false;\n\t\/\/ This example assumes the addition of an additional request parameter. However, any logic could be used here.\n\tif ( isset( $_REQUEST&#91;'mc_api_key'] ) ) {\n\t\t$valid = your_validate_key( $_REQUEST&#91;'mc_api_key'] );\n\t}\n\n\treturn $valid;\n}\nadd_filter( 'mc_api_key', 'your_api_key' );\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The My Calendar exports API is enabled at My Calendar > Settings > General. This API allows you to generate a CSV, JSON, or iCal formatted export of My Calendar event data. The API is not enabled by default. Once enabled, you can access it using URL parameters on your site: The my-calendar-api parameter is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1112","post","type-post","status-publish","format-standard","hentry","category-settings"],"_links":{"self":[{"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/posts\/1112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/comments?post=1112"}],"version-history":[{"count":3,"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/posts\/1112\/revisions"}],"predecessor-version":[{"id":1118,"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/posts\/1112\/revisions\/1118"}],"wp:attachment":[{"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/media?parent=1112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/categories?post=1112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.joedolson.com\/my-calendar\/wp-json\/wp\/v2\/tags?post=1112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}