Google Calendar API

Colors: get

Returns the color definitions for calendars and events. Try it now or see an example.

Request

HTTP request

GET https://www.googleapis.com/calendar/v3/colors

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a Colors resource in the response body.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

Colors colors = service.colors().get().execute();

// Print available calendarListEntry colors.
for (Map.Entry<String, ColorDefinition> color : colors.getCalendar().entrySet()) {
  System.out.println("ColorId : " + color.getKey());
  System.out.println("  Background: " + color.getValue().getBackground());
  System.out.println("  Foreground: " + color.getValue().getForeground());
}
// Print available event colors.
for (Map.Entry<String, ColorDefinition> color : colors.getEvent().entrySet()) {
  System.out.println("ColorId : " + color.getKey());
  System.out.println("  Background: " + color.getValue().getBackground());
  System.out.println("  Foreground: " + color.getValue().getForeground());
}

Python

Uses the Python client library.

colors = service.colors().get().execute()

# Print available calendarListEntry colors.
for id, color in colors['calendar'].iteritem():
  print 'colorId: %s' % id
  print '  Background: %s' % color['background']
  print '  Foreground: %s' % color['foreground']
# Print available event colors.
for id, color in colors['event'].iteritem():
  print 'colorId: %s' % id
  print '  Background: %s' % color['background']
  print '  Foreground: %s' % color['foreground']

PHP

Uses the PHP client library.

$colors = $service->colors->get();

// Print available calendarListEntry colors.
foreach ($colors->getCalendar() as $key => $color) {
  print "colorId : {$key}\n";
  print "  Background: {$color->getBackground()}\n";
  print "  Foreground: {$color->getForeground()}\n";
}
// Print available event colors.
foreach ($colors->getEvent() as $key => $color) {
  print "colorId : {$key}\n";
  print "  Background: {$color->getBackground()}\n";
  print "  Foreground: {$color->getForeground()}\n";
}

Ruby

Uses the Ruby client library.

result = client.execute(:api_method => service.colors.get)

# Print available calendarListEntry colors.
entries = result.data.calendar
keys = entries.to_hash.keys
keys.each do |key|
  print "colorId: #{key}\n"
  print "  Background: #{entries[key]['background']}\n"
  print "  Foreground: #{entries[key]['foreground']}\n"
end

# Print available event colors.
entries = result.data.event
keys = entries.to_hash.keys
keys.each do |key|
  print "colorId: #{key}\n"
  print "  Background: #{entries[key]['background']}\n"
  print "  Foreground: #{entries[key]['foreground']}\n"
end

.NET

Uses the .NET client library.

Colors colors = service.Colors.Get().Fetch();

// Print available calendarListEntry colors.
foreach (KeyValuePair<String, ColorDefinition> color in colors.Calendar) {
  System.out.println("ColorId : " + color.Key);
  System.out.println("  Background: " + color.Value.Background);
  System.out.println("  Foreground: " + color.Value.Foreground);
}
// Print available event colors.
foreach (KeyValuePair<String, ColorDefinition> color in colors.Event) {
  System.out.println("ColorId : " + color.Key);
  System.out.println("  Background: " + color.Value.Background);
  System.out.println("  Foreground: " + color.Value.Foreground);
}

Try it!

Use the APIs Explorer below to call this method on live data and see the response.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.