πŸ“… Calendar API Documentation

Parse ICS calendar feeds and retrieve meeting details within a date range

Overview

The Calendar API allows you to fetch and parse ICS (iCalendar) files from URLs and retrieve meeting details for a specified date range. The API automatically handles recurring events and converts times to your specified timezone.

πŸ”„ Recurring Events

Automatically calculates and includes recurring meetings based on RRULE specifications

🌍 Timezone Support

Converts all times to your specified timezone for consistent results

πŸ‘₯ Participant Extraction

Extracts and lists all meeting participants from attendee information

πŸ“‹ Complete Details

Returns meeting names, times, descriptions, locations, and more

Endpoint

GET /calendar.php

Request Parameters

Parameter Type Required Description
ics_url string (URL) Required The URL of the ICS calendar file to parse. Must be publicly accessible.
start_date string (date) Required The start date for the event range. Format: YYYY-MM-DD or any format accepted by PHP's DateTime.
end_date string (date) Required The end date for the event range. Format: YYYY-MM-DD or any format accepted by PHP's DateTime.
timezone string Optional The timezone for date/time output. Defaults to UTC. Must be a valid PHP timezone identifier (e.g., America/New_York, Europe/London).
Note: The API will include all events that start within the specified date range, including occurrences of recurring events.

Response Format

Success Response

When the request is successful, the API returns a JSON object with the following structure:

{
  "success": true,
  "data": [
    {
      "name": "Team Standup",
      "start_time": "2025-10-08 09:00:00",
      "end_time": "2025-10-08 09:30:00",
      "participants": [
        "John Doe",
        "Jane Smith",
        "bob@example.com"
      ],
      "details": "Daily team sync meeting to discuss progress and blockers.",
      "location": "Conference Room A",
      "timezone": "America/New_York"
    },
    ...
  ],
  "count": 15
}

Response Fields

Field Type Description
success boolean Indicates whether the request was successful
data array Array of meeting objects, sorted by start time
count integer Total number of meetings returned

Meeting Object Fields

Field Type Description
name string The title/summary of the meeting
start_time string Meeting start time in format YYYY-MM-DD HH:MM:SS
end_time string|null Meeting end time in format YYYY-MM-DD HH:MM:SS, or null if not specified
participants array Array of participant names or email addresses
details string Meeting description or additional details
location string Meeting location (physical or virtual)
timezone string The timezone used for the start_time and end_time

Error Response

When an error occurs, the API returns:

{
  "success": false,
  "error": "Error message describing what went wrong"
}
Common Error Messages:
  • "ICS URL is required."
  • "Start date is required."
  • "End date is required."
  • "Invalid timezone: [timezone]"
  • "Start date must be before or equal to end date."
  • "Failed to fetch ICS file from URL."

Examples

Example 1: Basic Request

Request:
GET /calendar.php?ics_url=https://example.com/calendar.ics&start_date=2025-10-01&end_date=2025-10-31&timezone=America/New_York
Response:
{
  "success": true,
  "data": [
    {
      "name": "Weekly Team Meeting",
      "start_time": "2025-10-01 10:00:00",
      "end_time": "2025-10-01 11:00:00",
      "participants": [
        "Alice Johnson",
        "Bob Smith",
        "carol@company.com"
      ],
      "details": "Weekly sync to discuss project progress",
      "location": "Room 301",
      "timezone": "America/New_York"
    },
    {
      "name": "Client Presentation",
      "start_time": "2025-10-03 14:00:00",
      "end_time": "2025-10-03 15:30:00",
      "participants": [
        "John Doe",
        "client@external.com"
      ],
      "details": "Q3 results presentation for major client",
      "location": "Zoom: https://zoom.us/j/123456",
      "timezone": "America/New_York"
    }
  ],
  "count": 2
}

Example 2: Single Day Query

Request:
GET /calendar.php?ics_url=https://example.com/calendar.ics&start_date=2025-10-08&end_date=2025-10-08&timezone=Europe/London
Response:
{
  "success": true,
  "data": [
    {
      "name": "Morning Standup",
      "start_time": "2025-10-08 09:00:00",
      "end_time": "2025-10-08 09:15:00",
      "participants": ["Team"],
      "details": "",
      "location": "",
      "timezone": "Europe/London"
    }
  ],
  "count": 1
}

Example 3: Using JavaScript Fetch

Code:
const params = new URLSearchParams({
  ics_url: 'https://example.com/calendar.ics',
  start_date: '2025-10-01',
  end_date: '2025-10-31',
  timezone: 'America/Los_Angeles'
});

fetch(`/calendar.php?${params}`)
  .then(response => response.json())
  .then(data => {
    if (data.success) {
      console.log(`Found ${data.count} meetings:`);
      data.data.forEach(meeting => {
        console.log(`${meeting.name} at ${meeting.start_time}`);
      });
    } else {
      console.error('Error:', data.error);
    }
  })
  .catch(error => console.error('Request failed:', error));

Example 4: Using PHP as a Function

Code:
// Include the calendar.php file
require_once 'calendar.php';

// Call the function directly
$result = get_calendar_events([
    'ics_url' => 'https://example.com/calendar.ics',
    'start_date' => '2025-10-01',
    'end_date' => '2025-10-31',
    'timezone' => 'America/Chicago'
]);

if ($result['success']) {
    echo "Found " . $result['count'] . " meetings:\n";
    foreach ($result['data'] as $meeting) {
        echo $meeting['name'] . " - " . $meeting['start_time'] . "\n";
    }
} else {
    echo "Error: " . $result['error'];
}

Recurring Events

The API automatically handles recurring events based on RRULE specifications in the ICS file. Supported recurrence patterns include:

Note: The API respects COUNT (maximum occurrences) and UNTIL (end date) parameters in recurrence rules. For safety, a maximum of 1000 iterations is enforced for recurring events.

Example Recurring Event

If your ICS file contains a weekly recurring meeting every Monday at 10:00 AM, and you query for October 2025, the API will return all Monday occurrences in that month:

{
  "success": true,
  "data": [
    {
      "name": "Weekly Sync",
      "start_time": "2025-10-06 10:00:00",
      ...
    },
    {
      "name": "Weekly Sync",
      "start_time": "2025-10-13 10:00:00",
      ...
    },
    {
      "name": "Weekly Sync",
      "start_time": "2025-10-20 10:00:00",
      ...
    },
    {
      "name": "Weekly Sync",
      "start_time": "2025-10-27 10:00:00",
      ...
    }
  ],
  "count": 4
}

Timezone Support

The API supports all standard PHP timezone identifiers. Some common examples:

πŸ‡ΊπŸ‡Έ United States

America/New_York
America/Chicago
America/Denver
America/Los_Angeles

πŸ‡ͺπŸ‡Ί Europe

Europe/London
Europe/Paris
Europe/Berlin
Europe/Moscow

🌏 Asia

Asia/Tokyo
Asia/Shanghai
Asia/Singapore
Asia/Dubai

🌍 Other

Australia/Sydney
Pacific/Auckland
Africa/Cairo
UTC
Full List: For a complete list of supported timezones, visit: php.net/manual/en/timezones.php

Best Practices

Limitations

Testing the API

You can test the API using various methods:

Using cURL

curl "https://yourdomain.com/calendar.php?ics_url=https://example.com/calendar.ics&start_date=2025-10-01&end_date=2025-10-31&timezone=UTC"

Using Browser

Simply paste the URL with parameters into your browser's address bar:

https://yourdomain.com/calendar.php?ics_url=https://example.com/calendar.ics&start_date=2025-10-01&end_date=2025-10-31&timezone=America/New_York

Using Postman

  1. Create a new GET request
  2. Enter the base URL: https://yourdomain.com/calendar.php
  3. Add query parameters in the Params tab
  4. Click Send