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.

My Calendar > Settings > General

The API is not enabled by default. Once enabled, you can access it using URL parameters on your site:

http://www.example.com/?my-calendar-api=json&from=2021-02-01&to=2022-01-31

The my-calendar-api parameter is used to set the export format, and accepts json, csv, and ical as options.

Parameters

  • my-calendar-api: format to return, ‘json’, ‘csv’, ‘ical’
  • from: starting date to retrieve, YYYY-MM-DD (default: current date.)
  • to: end date to retrieve, YYYY-MM-DD (default: 7 days from today.)
  • mcat: Category ID to limit by.
  • ltype: Location type to restrict to (keywords: ‘name’, ‘city’, ‘state’, ‘zip’, ‘country’, ‘region’)
  • lvalue: Location value to match against location field type
  • author: Events by author ID
  • host: Events by host ID.
  • search: text search query terms.

Private events are automatically excluded from exports.

Once enabled, the export API is public by default. You can restrict access to the API using your own program logic using the filter mc_api_key.

/**
 * Check for and validate access to the My Calendar exports API.
 *
 * @return bool False to block; true to allow.
 */
function your_api_key() {
	$valid = false;
	// This example assumes the addition of an additional request parameter. However, any logic could be used here.
	if ( isset( $_REQUEST['mc_api_key'] ) ) {
		$valid = your_validate_key( $_REQUEST['mc_api_key'] );
	}

	return $valid;
}
add_filter( 'mc_api_key', 'your_api_key' );