CalendarAPI is a service that parses iCal files and exposes their content via gRPC or a REST API. It uses Viper for configuration, which supports runtime reloads.
- โ Parse iCal (.ics) files from URLs or local files
- โ Exposes events via REST and gRPC APIs
- โ Built-in rule engine for relabeling, filtering, and skipping events
- โ Supports hot configuration reloads (with Viper)
- โ HomeAssistant Add-On to easily host CalendarAPI on your Home Assistant
server:
server: "" # ! Does not support changing at runtime
httpPort: 8080 # ! Does not support changing at runtime
grpcPort: 50051 # ! Does not support changing at runtime
debug: false # Control if debug logs are printed
refresh: 5m # how often are the calendars refreshed? Must be parsable by time.ParseDuration()
It is possible to add multiple iCal calendar feeds to pull multiple calendars from multiple sources. ical files can be read either from a URL or from a local file
calendars:
calendar1:
from: file
ical: ./path/to/calender1.ics
calendar2:
from: url
ical: www.example.com/calendar/calendar.ics
Rules allow you to filter events, or apply re-labeling. Rules are evaluated in the order of which they are specified in. The rule-evaluation stops after the event matches the first rule.
The rule below matches if the Title
of your calendar event contains the string 1:1
and then sets the display message to 1:1
as well as marking the event as important
rules:
- name: "1:1s"
key: "title"
contains:
- "1:1"
relabelConfig:
message: "1:1"
important: true
If a rule specifies skip: true
then each calendar event that matches this rule is excluded from the API responses.
Below are examples to skip all day and non-blocking events:
rules:
- name: "Skip all day events"
key: "all_day"
contains:
- "true"
skip: true
- name: "Skip non-blocking events"
key: "busy"
contains:
- "Free"
skip: true
You can use *
as a wildcard to match everything. If key
uses the wildcard, it will search all fields.
This is useful for catch-all rules that allow all other events that did not match previous rules to be included in the API responses.
rules:
- name: "Allow everything else"
key: "*"
important: false
contains:
- "*"
- Go 1.24+
- Docker (for building and running containers)
To build the project, run:
go build -o calendarapi main.go
To run the project, execute:
./calendarapi
To build and run the Docker container, use the following commands:
docker build -t calendarapi .
docker run -p 8080:8080 -p 50051:50051 calendarapi
To run tests, use:
go test ./...
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.