Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status Gem Version

Cronofy - one API for all the calendars (Google, iCloud, Exchange, Office 365,


Add this line to your application's Gemfile:

gem 'cronofy'

And then at your command prompt run:

bundle install


In order to use the Cronofy API you will need to create a developer account.

From there you can use your Calendar Sandbox to access your own calendars, or you can create an OAuth application to obtain an OAuth client_id and client_secret to be able to use the full API.

Creating a client

To make calls to the Cronofy API you must create a Cronofy::Client. This takes four keyword arguments, all of which are optional:

cronofy =
  client_id:     'CLIENT_ID',
  client_secret: 'CLIENT_SECRET',
  access_token:  'ACCESS_TOKEN',
  refresh_token: 'REFRESH_TOKEN'

When using a personal access token you only need to provide the access_token argument.

When working against your own OAuth application you will need to provide the client_id and client_secret when going through the authorization process for a user, and when refreshing an access token.

If client_id and client_secret are not specified explicitly the values from the environment variables CRONOFY_CLIENT_ID and CRONOFY_CLIENT_SECRET will be used if present.


API documentation

Generate a link for a user to grant access to their calendars:

authorization_url = cronofy.user_auth_link('')

The callback URL is a page on your website that will handle the OAuth 2.0 callback and receive a code parameter. You can then use that code to retrieve an OAuth token granting access to the user's Cronofy account:

response = cronofy.get_token_from_code(code, '')

You should save the response's access_token and refresh_token for later use.

Note that the exact same callback URL must be passed to both methods for access to be granted.

If you use the omniauth gem, you can use our omniauth-cronofy strategy gem to perform this process.

List calendars

API documentation

Get a list of all the user's calendars:

calendars = cronofy.list_calendars

Read events

API documentation

Get a list of events from the user's calendars:

events = cronofy.read_events

Note that the gem handles iterating through the pages on your behalf.

Create or update events

API documentation

To create/update an event in the user's calendar:

event_data = {
  event_id: 'uniq-id',
  summary: 'Event summary',
  description: 'Event description',
  start: + 60 * 60 * 24,
  end: + 60 * 60 * 25,
  location: {
    description: "Meeting room"

cronofy.upsert_event(calendar_id, event_data)

Delete events

API documentation

To delete an event from user's calendar:

cronofy.delete_event(calendar_id, 'uniq-id')


You can’t perform that action at this time.