# Multi-Source ICS Calendar Merge and Duplicate-Event Publisher (`kingii98/multi-source-ics-calendar-merge-and-duplicate-event-publisher`) Actor

Merge 2 to 50 ICS feeds into one subscribable ICS file at a stable key-value record. Remove duplicate events.

- **URL**: https://apify.com/kingii98/multi-source-ics-calendar-merge-and-duplicate-event-publisher.md
- **Developed by:** [kingii98](https://apify.com/kingii98) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 source feed mergeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Multi-Source ICS Calendar Merge and Duplicate-Event Publisher

This Actor merges 2 to 50 public ICS feeds into one ICS file. It removes duplicate events.
It writes the file to a named key-value store at a fixed record key. Subscribers add the URL once.

### Input

| Field | Default | Meaning |
| --- | --- | --- |
| `sources` | two public holiday feeds | 2 to 50 objects: `url`, `label`, optional `prefix` (for example `[Group A]`). |
| `windowDays` | 120 | Days forward to include. Maximum 365. |
| `dedupeToleranceMinutes` | 15 | Start-time tolerance for the summary rule. |
| `calendarName` | `Merged calendar` | `X-WR-CALNAME` of the output file. |
| `outputKey` | `merged.ics` | Record key of the merged file. Keep it the same on each run. |
| `storeName` | `merged-calendar` | Named key-value store. |

An empty input `{}` runs with the defaults and succeeds.

### Duplicate rules

- Same UID in a different source, at any start time.
- Same normalized SUMMARY (without the prefix), same normalized LOCATION, and start times within the tolerance.

The first source in the list has priority. The Actor keeps its event.
A recurring event is expanded into single events. When a UID occurs more than once in the window, each instance gets a UID with a start-time suffix.

### Output

- Key-value record `outputKey` in the named store: the merged ICS file. Each event has an `X-SOURCE-LABEL` property. The file copies the VTIMEZONE parts of the sources.
- Dataset: one row for each duplicate cluster (maximum 200): `keptUid`, `removedUids`, `sourceLabels`, `matchReason`. Then one `summary` row: `sourcesFetched`, `sourcesFailed`, `eventsIn`, `eventsOut`, `recordUrl`.
- Default store record `SUMMARY`: the same summary row.

A failed source, or a run with no usable source, does not fail the run. The summary row and the status message report it. The Actor does not publish a file when no source can be fetched.

### Pay-per-event

| Event | Charged | Count |
| --- | --- | --- |
| `source-feed-merged` | One source feed fetched, expanded, and added to the merge. | Number of sources fetched without error. |
| `calendar-published` | One merged file written to the stable record key. It includes the run start and the duplicate report. | 1 for each published file. |

The Actor does not charge for a failed source. It does not charge when it publishes no file.

### Subscriber downloads are not charged by the Actor

Downloads of the merged file by subscribers count as storage transfer on **your** Apify account.
The Actor does not charge for them. The record must be publicly readable. This depends on the access setting of your storage. Confirm the setting before you share the URL.

### Limits and safety

- HTTP GET only. No browser, no proxy, no paid API, no external database.
- Only `http` and `https` URLs. `webcal://` is changed to `https://`.
- The Actor rejects localhost, private, and reserved addresses. It checks every redirect. Maximum 3 redirects.
- Maximum 2 MB for each feed, 20 s timeout, 5 parallel fetches, 5,000 event instances in total.
- Known limit: the address check and the connection use two separate DNS lookups.

### Development

```
uv run pytest
uv run ruff check .
```

# Actor input Schema

## `sources` (type: `array`):

2 to 50 public ICS feeds. Each item has url, label, and an optional prefix for the event summary.

## `windowDays` (type: `integer`):

Days forward to include. Maximum 365.

## `dedupeToleranceMinutes` (type: `integer`):

Two events with the same normalized summary and location are duplicates when their start times differ by this many minutes or less. Events with the same UID in a different source are always duplicates, at any start time.

## `calendarName` (type: `string`):

Value of X-WR-CALNAME in the output file.

## `outputKey` (type: `string`):

Key-value record name for the merged file. Use the same key on each run to keep the subscriber URL.

## `storeName` (type: `string`):

Named key-value store that holds the merged file.

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics",
      "label": "US holidays",
      "prefix": "[US]"
    },
    {
      "url": "https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics",
      "label": "UK holidays",
      "prefix": "[UK]"
    }
  ],
  "windowDays": 120,
  "dedupeToleranceMinutes": 15,
  "calendarName": "Merged calendar",
  "outputKey": "merged.ics",
  "storeName": "merged-calendar"
}
```

# Actor output Schema

## `report` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "sources": [
        {
            "url": "https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics",
            "label": "US holidays",
            "prefix": "[US]"
        },
        {
            "url": "https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics",
            "label": "UK holidays",
            "prefix": "[UK]"
        }
    ],
    "windowDays": 120,
    "dedupeToleranceMinutes": 15,
    "calendarName": "Merged calendar",
    "outputKey": "merged.ics",
    "storeName": "merged-calendar"
};

// Run the Actor and wait for it to finish
const run = await client.actor("kingii98/multi-source-ics-calendar-merge-and-duplicate-event-publisher").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "sources": [
        {
            "url": "https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics",
            "label": "US holidays",
            "prefix": "[US]",
        },
        {
            "url": "https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics",
            "label": "UK holidays",
            "prefix": "[UK]",
        },
    ],
    "windowDays": 120,
    "dedupeToleranceMinutes": 15,
    "calendarName": "Merged calendar",
    "outputKey": "merged.ics",
    "storeName": "merged-calendar",
}

# Run the Actor and wait for it to finish
run = client.actor("kingii98/multi-source-ics-calendar-merge-and-duplicate-event-publisher").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sources": [
    {
      "url": "https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics",
      "label": "US holidays",
      "prefix": "[US]"
    },
    {
      "url": "https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics",
      "label": "UK holidays",
      "prefix": "[UK]"
    }
  ],
  "windowDays": 120,
  "dedupeToleranceMinutes": 15,
  "calendarName": "Merged calendar",
  "outputKey": "merged.ics",
  "storeName": "merged-calendar"
}' |
apify call kingii98/multi-source-ics-calendar-merge-and-duplicate-event-publisher --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kingii98/multi-source-ics-calendar-merge-and-duplicate-event-publisher"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/iZBjWocudVzpbKkgY/builds/qmrFZif39eWTzkuxA/openapi.json
