A Python server that aggregates multiple Google Calendars into a single iCalendar (.ics) feed that can be subscribed to by any calendar appl
Files
README.md

GCals to iCal #

A Python server that aggregates multiple Google Calendars into a single iCalendar (.ics) feed that can be subscribed to by Google Calendar, Apple Calendar, or any other calendar application that supports iCalendar feeds.

Features #

  • Fetches events from multiple Google Calendars
  • Combines all events into a single iCalendar feed
  • Serves the feed via HTTP endpoint for easy subscription
  • Modern web UI for easy calendar access and subscription
  • No browser-based OAuth required - uses API keys
  • Supports both all-day and timed events
  • Preserves event metadata (descriptions, locations, attendees, etc.)

Prerequisites #

  • Python 3.12 or higher
  • Node.js 18+ and npm (for frontend development)
  • Google Cloud Project with Calendar API enabled
  • Google Calendar API Key

Setup #

1. Install Backend Dependencies #

Install uv, then run the following at the root of the project:

uv sync

2. Install Frontend Dependencies #

Navigate to the frontend directory and install dependencies:

cd frontend
npm install
cd ..

Alternatively, you can build everything at once using the build script (see below).

3. Set Up Google Calendar API #

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Google Calendar API:
    • Navigate to "APIs & Services" > "Library"
    • Search for "Google Calendar API"
    • Click "Enable"

4. Set up authentication #

API Key #

This is the simplest option if your calendars are public or you can make them public.

  1. Create an API Key:

    • Go to "APIs & Services" > "Credentials"
    • Click "Create Credentials" > "API key"
    • Copy the API key
    • (Optional) Restrict the API key to Google Calendar API for security
  2. Make your calendars public (if they aren't already):

    • Open Google Calendar
    • Go to Settings > Settings for my calendars
    • Click on the calendar you want to include
    • Scroll down to "Access permissions"
    • Check "Make available to public"
    • Select "See all event details"

To build the frontend for production:

./build.sh

Or manually:

cd frontend
npm install
npm run build
cd ..

This will create a static/ directory with the built frontend files that FastAPI will serve.

6. Configure Environment Variables #

Create a .env file in the project root:

For API Key:

# Comma-separated list of Google Calendar IDs
GOOGLE_CALENDAR_IDS=calendar1@gmail.com,calendar2@gmail.com,calendar3@gmail.com

# Google API Key (for public calendars)
GOOGLE_API_KEY=your-api-key-here

# Optional: Server configuration
# HOST=0.0.0.0
# PORT=8000

Usage #

Running the Server #

python main.py

The server will start on http://0.0.0.0:8000 by default.

If you've built the frontend, you can access the web UI at http://localhost:8000 in your browser. The UI provides:

  • Download calendar button
  • Copy calendar URL functionality
  • Service health status
  • Instructions for subscribing to the calendar

Development Mode #

For frontend development with hot-reload:

# Terminal 1: Run the backend
python main.py

# Terminal 2: Run the frontend dev server
cd frontend
npm run dev

The frontend dev server will run on http://localhost:5173 (or another port) and proxy API requests to the backend.

Endpoints #

  • GET / - Serves the frontend UI (if built) or returns API information
  • GET /calendar.ics - The aggregated iCalendar feed (main endpoint)
  • GET /health - Health check endpoint
  • GET /static/* - Static frontend assets (CSS, JS, etc.)

Subscribing to the Calendar #

Google Calendar #

  1. Open Google Calendar
  2. Click the "+" next to "Other calendars"
  3. Select "From URL"
  4. Enter: http://server-address/calendar.ics
  5. Click "Add calendar"

Apple Calendar #

  1. Open Calendar app
  2. Go to File > New Calendar Subscription
  3. Enter: http://server-address/calendar.ics
  4. Configure update frequency and other options
  5. Click "OK"

Configuration #

All configuration is done via environment variables in the .env file:

  • GOOGLE_API_KEY (optional): Google API key for public calendars
  • HOST (optional): Server host (default: 0.0.0.0)
  • PORT (optional): Server port (default: 8000)

How It Works #

  1. Authentication: Uses an API key to fetch events from the provided public calendars
  2. Event Fetching: Fetches events from all configured calendars (default: 30 days ago to 365 days ahead)
  3. Conversion: Converts Google Calendar events to iCalendar format
  4. Aggregation: Combines all events into a single iCalendar feed
  5. Serving: Serves the feed via HTTP endpoint with proper headers for calendar subscription

Troubleshooting #

"Error fetching events from calendar" #

  • Verify the calendar ID is correct in src/assets/calendar_sources.json
  • Ensure the calendar is set to public
  • Check that the Calendar API is enabled in your Google Cloud project

API Key Restrictions #

If you've restricted your API key, make sure:

  • The Google Calendar API is allowed
  • Your server's IP address is in the allowed list (if IP restrictions are set)

License #

This project is open source and available under the MIT License.