A simple API that accepts event parameters and returns calendar links for both Google Calendar and Apple Calendar.
- ✅ Generate Google Calendar links
- ✅ Generate Apple Calendar (.ics) links
- ✅ Support for both GET and POST requests
- ✅ Input validation and error handling
- ✅ Documentation page at root URL
Returns an HTML documentation page with usage examples and API reference.
Generate calendar links from JSON payload.
Request Body:
{ "title": "Team Meeting", "description": "Weekly team sync", "location": "Conference Room A", "startDate": "2024-01-15T10:00:00Z", "endDate": "2024-01-15T11:00:00Z", "timezone": "America/New_York" }
Required fields: title, startDate, endDate
Optional fields: description, location, timezone
Generate calendar links from query parameters.
Example:
/api/calendar-link?title=Meeting&startDate=2024-01-15T10:00:00Z&endDate=2024-01-15T11:00:00Z&description=Team meeting&location=Conference Room A
Both endpoints return the same JSON response format:
{ "success": true, "event": { "title": "Team Meeting", "description": "Weekly team sync", "location": "Conference Room A", "startDate": "2024-01-15T10:00:00Z", "endDate": "2024-01-15T11:00:00Z", "timezone": "America/New_York" }, "links": { "google": "https://calendar.google.com/calendar/render?action=TEMPLATE&text=...", "apple": "data:text/calendar;charset=utf8,..." } }
Use ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ (e.g., 2024-01-15T10:00:00Z)
Use the google link directly in a browser or as a redirect. Users will be taken to Google Calendar with the event pre-filled.
Use the apple link as a download link for an .ics file. This will work with Apple Calendar, Outlook, and other calendar applications that support the iCalendar format.
POST request:
curl -X POST https://your-val-url.web.val.run/api/calendar-link \ -H "Content-Type: application/json" \ -d '{ "title": "Product Demo", "description": "Quarterly product demonstration", "location": "Main Conference Room", "startDate": "2024-02-20T14:00:00Z", "endDate": "2024-02-20T15:30:00Z" }'
GET request:
curl "https://your-val-url.web.val.run/api/calendar-link?title=Meeting&startDate=2024-01-15T10:00:00Z&endDate=2024-01-15T11:00:00Z"
// Using fetch API
const response = await fetch('/api/calendar-link', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
title: 'Team Meeting',
description: 'Weekly team sync',
location: 'Conference Room A',
startDate: '2024-01-15T10:00:00Z',
endDate: '2024-01-15T11:00:00Z'
})
});
const data = await response.json();
// Redirect to Google Calendar
window.location.href = data.links.google;
// Or download .ics file for Apple Calendar
const link = document.createElement('a');
link.href = data.links.apple;
link.download = 'event.ics';
link.click();
The API returns appropriate HTTP status codes and error messages:
400 Bad Request- Missing required fields, invalid date format, or invalid JSON200 OK- Successful response with calendar links
Example error response:
{ "error": "Missing required fields: title, startDate, and endDate are required" }
- Built with Hono framework for fast HTTP handling
- Generates Google Calendar URLs using the official Google Calendar URL scheme
- Creates iCalendar (.ics) files for Apple Calendar compatibility
- Validates input data and provides helpful error messages
- Supports both GET and POST methods for flexibility