- Python 58%
- JavaScript 26%
- CSS 12%
- Makefile 2%
- HTML 1%
- 1 more language <1%
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 #
- Go to the Google Cloud Console
- Create a new project or select an existing one
- 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.
-
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
-
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"
5. Build the Frontend (Optional but Recommended) #
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 informationGET /calendar.ics- The aggregated iCalendar feed (main endpoint)GET /health- Health check endpointGET /static/*- Static frontend assets (CSS, JS, etc.)
Subscribing to the Calendar #
Google Calendar #
- Open Google Calendar
- Click the "+" next to "Other calendars"
- Select "From URL"
- Enter:
http://server-address/calendar.ics - Click "Add calendar"
Apple Calendar #
- Open Calendar app
- Go to File > New Calendar Subscription
- Enter:
http://server-address/calendar.ics - Configure update frequency and other options
- Click "OK"
Configuration #
All configuration is done via environment variables in the .env file:
GOOGLE_API_KEY(optional): Google API key for public calendarsHOST(optional): Server host (default:0.0.0.0)PORT(optional): Server port (default:8000)
How It Works #
- Authentication: Uses an API key to fetch events from the provided public calendars
- Event Fetching: Fetches events from all configured calendars (default: 30 days ago to 365 days ahead)
- Conversion: Converts Google Calendar events to iCalendar format
- Aggregation: Combines all events into a single iCalendar feed
- 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.