All Projects → yuhong90 → node-google-calendar

yuhong90 / node-google-calendar

Licence: ISC license
Simple node module that supports Google Calendar API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-google-calendar

Laravel Google Calendar
Manage events on a Google Calendar
Stars: ✭ 787 (+935.53%)
Mutual labels:  events, calendar, google-calendar
google-calendar-api
Demo Project for Google Calendar API Using Spring Boot Rest API with OAuth2
Stars: ✭ 25 (-67.11%)
Mutual labels:  calendar, google-calendar, google-api
Fb2cal
Fetch Facebook Birthdays events and create an ICS file for use with calendar apps
Stars: ✭ 335 (+340.79%)
Mutual labels:  events, calendar, google-calendar
prodcal ics
Производственный календарь в формате ics
Stars: ✭ 23 (-69.74%)
Mutual labels:  calendar, google-calendar
Easyappointments
Easy!Appointments is a highly customizable web application that allows customers to book appointments with you via a sophisticated web interface. Moreover, it provides the ability to sync your data with Google Calendar so you can use them with other services. It is an open source project that you can download and install even for commercial use. Easy!Appointments will run smoothly with your existing website as it can be installed in a single folder of the server and of course share an existing database.
Stars: ✭ 2,013 (+2548.68%)
Mutual labels:  events, google-calendar
Flutter Timeline
⌚️ A general flutter timeline widget based on real-world application references
Stars: ✭ 142 (+86.84%)
Mutual labels:  events, calendar
Calendar
Календарь событий по фронтенду
Stars: ✭ 395 (+419.74%)
Mutual labels:  events, calendar
Lwt
OCaml promises and concurrent I/O
Stars: ✭ 505 (+564.47%)
Mutual labels:  promises, events
React Native Add Calendar Event
Create, view or edit events in react native using the standard iOS / Android dialogs
Stars: ✭ 225 (+196.05%)
Mutual labels:  events, calendar
wp-event-calendar
The best way to manage events in WordPress
Stars: ✭ 46 (-39.47%)
Mutual labels:  events, calendar
datebook
📅 Generates URLs and downloadable ICS files for adding events to popular calendar apps.
Stars: ✭ 273 (+259.21%)
Mutual labels:  calendar, google-calendar
Ls.joyous
A calendar application for Wagtail
Stars: ✭ 53 (-30.26%)
Mutual labels:  events, calendar
Forcal
📅 Das AddOn ist ein variabel einsetzbarer Kalender(-Generator), Skedule, Newssystem, Event- und Terminplaner für REDAXO 5.x.
Stars: ✭ 52 (-31.58%)
Mutual labels:  events, calendar
Quasar Ui Qcalendar
QCalendar - Quasar App Extension, Vue CLI plug-in and UMD distributions available
Stars: ✭ 148 (+94.74%)
Mutual labels:  events, calendar
aircal
Visualize Airflow's schedule by exporting future DAG runs as events to Google Calendar.
Stars: ✭ 66 (-13.16%)
Mutual labels:  calendar, google-calendar
ics2gcal
Import .ics files into Google Calendar with only two clicks.
Stars: ✭ 21 (-72.37%)
Mutual labels:  google-calendar, google-api
js-training
JS Training Course
Stars: ✭ 39 (-48.68%)
Mutual labels:  promises, events
Daylight-Calendar-ICS
Daylight Calendar is a dynamically generated .ics calendar that you can host and subscribe to in Google Calendar, iCal, or other calendar software.
Stars: ✭ 22 (-71.05%)
Mutual labels:  calendar, google-calendar
Cadar
Android solution which represents month and list calendar views.
Stars: ✭ 360 (+373.68%)
Mutual labels:  events, calendar
Bliss
Blissful JavaScript
Stars: ✭ 2,352 (+2994.74%)
Mutual labels:  promises, events

node-google-calendar

Build Status Known Vulnerabilities

Simple node module that supports Google Calendar API

This module does server to server authentication with Google APIs without any users being involved. When using Google APIs from the server (or any non-browser based application), authentication is performed through a Service Account, which is a special account representing your application.

Find out more about preparations needed to setting up the service account, grant calendar access, auth key to google and the configurations needed to start using node-google-calendar.

Getting Started

First, install the npm package with: npm i node-google-calendar --save.

Provide in a settings.js config file with serviceAcctId, calendarIds, timezone & keyfile location.
Check out preparations needed if you have trouble supplying these configurations. Sample config file here.

Your config file should look something like this:

const KEYFILE = '<yourpem.pem>';
const SERVICE_ACCT_ID = '<service_account>@<project_name>.iam.gserviceaccount.com';
const CALENDAR_ID = {
  'primary': '<main-calendar-id>@gmail.com',
  'calendar-1': '[email protected]',
  'calendar-2': '[email protected]'
};
const TIMEZONE = 'UTC+08:00';

module.exports.keyFile = KEYFILE;           //or if using json keys - module.exports.key = key;
module.exports.serviceAcctId = SERVICE_ACCT_ID;
module.exports.calendarId = CALENDAR_ID;
module.exports.timezone = TIMEZONE;

To use, require this module in your application and pass in the necessary config file.

  const CONFIG = require('./config/Settings');
  const CalendarAPI = require('node-google-calendar');
  let cal = new CalendarAPI(CONFIG);  

You should now be able to query your specified calendar and try out the following examples.

APIs

Most Google Calendar APIs v3 are now supported! This includes APIs in resource types of Calendars, CalendarList, Acl, Events, FreeBusy, Settings, Colors & Channels. You can refer to Google's documentation on what parameters to supply, and choose to include or exclude the parameters that you need.

Some examples are as follows:

CalendarList Examples

CalendarList.list - Returns a promise of a CalendarList of calendar entries and their metadata that the service account has visibility to.

let params = {
  showHidden: true
};

cal.CalendarList.list(params)
  .then(resp => {
	console.log(resp);
  }).catch(err => {
	console.log(err.message);
  });

Acl Examples

Acl.insert - Granting a user owner permission of to a calendar. Calendar entry should be automatically added to user's CalendarList after success. (Appear on calendarlist on left side of Google Calendar's WebUI)

let params = {
	scope: {
		type: 'user',
		value: '[email protected]'
	},
	role: 'owner'
};

cal.Acl.insert(calendarId, params)
  .then(resp => {
	console.log(resp);
  }).catch(err => {
	console.log(err.message);
  });

Events Examples

Events.list - To get a promise of all single events in calendar within a time period.

let params = {
	timeMin: '2017-05-20T06:00:00+08:00',
	timeMax: '2017-05-25T22:00:00+08:00',
	q: 'query term',
	singleEvents: true,
	orderBy: 'startTime'
}; 	//Optional query parameters referencing google APIs

cal.Events.list(calendarId, params)
  .then(json => {
	//Success
	console.log('List of events on calendar within time-range:');
	console.log(json);
  }).catch(err => {
	//Error
	console.log('Error: listSingleEvents -' + err.message);
  });

Events.insert - Insert an event on a specified calendar. Returns promise of details of new event.

let params = {
	'start': { 'dateTime': '2017-05-20T07:00:00+08:00' },
	'end': { 'dateTime': '2017-05-20T08:00:00+08:00' },
	'location': 'Coffeeshop',
	'summary': 'Breakfast',
	'status': 'confirmed',
	'description': '',
	'colorId': 1
};

cal.Events.insert(calendarId, params)
  .then(resp => {
	console.log('inserted event:');
	console.log(resp);
  })
  .catch(err => {
	console.log('Error: insertEvent-' + err.message);
  });

Events.delete - Deletes an Event on a specified Calendar with EventId. Returns promise of results.

let params = {
	sendNotifications: true
};

cal.Events.delete(calendarId, eventId, params)
  .then(results => {
	console.log('delete Event:' + JSON.stringify(results));
  }).catch(err => {
        console.log('Error deleteEvent:' + JSON.stringify(err.message));
  });

Events.patch - Specify part of an existing event to modify. Returns promise of results. Must specify the eventId (the "id" of an event) and any fields you'd like to modify. All other fields remain untouched.

cal.Events.patch(calendarId, eventId, {
       summary: "updated summary",
       ...
       ...
     })
     .then(results => {
       console.log("patched Event:" + JSON.stringify(results));
     })
     .catch(err => {
       console.log("Error patchedEvent:" + JSON.stringify(err.message));
     });
   })

FreeBusy Examples

FreeBusy.query - Checks if queried calendar slot is busy during selected period. Returns promise of list of events at specified slot.

let params = {
	"timeMin": '2017-05-20T08:00:00+08:00',
	"timeMax": '2017-05-20T09:00:00+08:00',
	"items": [{ "id": calendarId }]
};

cal.FreeBusy.query(calendarId, params)
  .then(resp => {
  	console.log('List of busy timings with events within defined time range: ');
        console.log(resp);
  })
  .catch(err => {
	console.log('Error: checkBusy -' + err.message);
  });

Settings Examples

Settings.list - List user settings

let params = {};
cal.Settings.list(params)
  .then(resp => {
	console.log('List settings: ');
	console.log(resp);
  })
  .catch(err => {
	console.log('Error: listSettings -' + err.message);
  });

More code examples of the various APIs here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].