Football Matches to Calendar

Automating Real Madrid fixture collection, match date filtering, and Google Calendar event synchronization using n8n.

n8n Schedule Trigger JavaScript football-data.org REST API Google Calendar API
Cron Trigger • Football Data API • Title Transformation • Google Calendar Sync Automated Match Synchronization Architecture

Project Overview

Football Matches to Calendar is a scheduled synchronization workflow designed to keep football supporters ahead of upcoming fixtures without manual scheduling. The workflow runs on an automated cadence, queries the football-data.org REST API for scheduled Real Madrid matches, formats kickoff times, and pushes them straight to Google Calendar.

Custom transformation code ensures match titles prioritize favorite team visibility (inverting away match titles so Real Madrid always appears first), calculates the exact match duration window, attaches venue and tournament details, and utilizes custom identifiers to ensure clean updates.

Schedule Cadence
Every 8 Days at 01:00 AM (Asia/Dhaka)
Target Club
Real Madrid (Team ID: 86)
Data Provider
football-data.org v4 REST API
Destination
Google Calendar Events

Problem & Solution

The Challenge

Football match schedules shift frequently due to domestic cup draws, European competitions, and television broadcast rescheduling. Fans either miss kick-off times or have to constantly verify match calendars and manually create calendar entries with local timezone conversions.

The Automation

An automated cron pipeline fetches verified upcoming match dates straight from sports databases, formats the title and description, and creates Google Calendar events spanning exactly 2 hours from kick-off so match days are automatically reflected on personal devices.

How It Works

1

Trigger on Schedule

Schedule Trigger

The workflow automatically wakes up every 8 days at 01:00 AM (configured in the Asia/Dhaka timezone). Running on an 8-day cycle guarantees scheduled matches for the coming weeks are consistently updated.

2

Supply Team Configuration

Code in JavaScript

A lightweight JavaScript node injects the target club identifier (id: 86, name: "Real Madrid") into the workflow stream, dynamically parameterizing the subsequent API query.

3

Retrieve Fixtures via Sports API

HTTP Request (football-data.org)

Executes an authenticated GET request to https://api.football-data.org/v4/teams/{{ $json.id }}/matches?status=SCHEDULED, pulling all verified scheduled fixtures.

4

Filter Window & Format Event Details

Code in JavaScript1

A data transformation script filters the retrieved matches within a strict 14-day window (from yesterday to 14 days ahead). It implements a customized title formatter: if Real Madrid is playing away, the script inverts the title (e.g. producing Real Madrid vs Sociedad instead of Sociedad vs Real Madrid). It sets event start time from match.utcDate, calculates end time as 2 hours after kick-off, generates an event ID prefixed with football, and compiles competition and stadium descriptions.

5

Create Google Calendar Events

Google Calendar (Create an event)

The Google Calendar node maps each transformed item into a calendar event with summary, description, start time, end time, and unique event ID. The node is configured with continueRegularOutput so individual event errors or collisions do not abort the workflow.

Linear Sync Pipeline Diagram

Scheduled Sync Architecture Source: Football Matches to Calendar.json
Cron Trigger
Schedule Trigger
Interval: 8 days @ 01:00 AM
→
Parameters
Code (Team Select)
Outputs Team ID: 86
→
REST API
HTTP Request
football-data.org v4
→
Transform
Code (Filter & Format)
14-day window + Title invert
→
Destination
Create an event
Google Calendar (2h duration)

Technical Highlights

Timezone-Aware Cron Schedule

Configured with Asia/Dhaka timezone settings and runs at 1 AM on an 8-day cycle to refresh match status without exhausting API quotas.

Away Team Title Normalization

The transformation checks if the user's club is the away team (isMyTeamAway) and inverts the title so the target club is always presented first in event alerts.

UTC Duration Calculation

Calculates event end time by adding 2 * 60 * 60 * 1000 milliseconds to match.utcDate, providing clean 2-hour match blocks in Google Calendar.

Error Continuation Handling

The Google Calendar node specifies onError: "continueRegularOutput", preventing individual event creation errors from crashing the overall workflow.

Technical Notes & Scope

Workflow Observations from Source JSON
  • Deduplication Scope: The workflow creates a deterministic ID (football + match.id) passed to Google Calendar's id field. Depending on Google Calendar API behavior for direct ID collisions, running multiple times without an update-or-create upsert step may return existing event errors, which are caught by the continueRegularOutput setting.
  • API Rate Limits: The free tier of football-data.org enforces call rate limitations (10 requests/minute). The 8-day trigger cycle stays well within quota boundaries.
  • Single Club Hardcoding: In the current workflow file, the club identifier is statically declared as Real Madrid (id: 86); expanding to multiple clubs would require an array iteration pattern.