BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Google Releases Mirror API for Glass

Google Releases Mirror API for Glass

Leia em Português

This item in japanese

Lire ce contenu en français

Google has released the Mirror API for writing Glassware applications and the final specification for Glass devices.

Google Glass uses the timeline concept consisting of a series of cards containing text, images, video or rich HTML. The user swipes his finger on the glass’ frame to navigate through cards. Cards are generated by the user, by taking a picture for example, or are received from a service the user has subscribed to. Cards can be grouped in a bundle, the user having the option to navigate through the entire set of cards or seeing just the cover of the bundle. Certain commands can be associated with cards: built-in ones such as Reply or Read Aloud, or custom ones created by a card developer.

From a developer’s perspective, working with Glass devices means writing a Glassware application using the Google Mirror API. This is a RESTful API using JSON for transferring data between devices and back end services. OAuth 2.0 is used for user authentication. Google intermediates all communication between these services and Glass devices.

Google is providing Java and Python starter projects along with a number of libraries for Go, PHP, .NET, Ruby and Dart programming.  The Java starter project can be demoed at https://glass-java-starter-demo.appspot.com/. Following is an example of inserting a card into the timelines using HTTP, Java and Python:

POST /mirror/v1/timeline HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer {auth token}
Content-Type: application/json
Content-Length: 26

{ "text": "Hello world" }
TimelineItem timelineItem = new TimelineItem();
timelineItem.setText("Hello world");
service.timeline().insert(timelineItem).execute();
timeline_item = {'text': 'Hello world'}
service.timeline().insert(body=timeline_item).execute()

On success, the server is supposed to return a 201 message with complete information regarding the item created:

HTTP/1.1 201 Created
Date: Tue, 25 Sep 2012 23:30:11 GMT
Content-Type: application/json
Content-Length: 303

{
"kind": "glass#timelineItem",
"id": "1234567890",
"selfLink": "https://www.googleapis.com/mirror/v1/timeline/1234567890",
"created": "2012-09-25T23:28:43.192Z",
"updated": "2012-09-25T23:28:43.192Z",
"etag": "\"G5BI0RWvj-0jWdBrdWrPZV7xPKw/t25selcGS3uDEVT6FB09hAG-QQ\"",
"text": "Hello world"
}

Other timeline-related operations are: reading cards in the timeline, bundling cards and accessing card attachments, the later containing binary information such as pictures.

Glassware applications can include subscriptions, the user being notified when accessing the timeline or when his location changes, location related operations such as rendering maps on cards, or managing contacts. All API calls are OAuth protected. The user can also interact with Google Now requesting information, dictating emails, setting appointments, etc. by issuing voice commands.

As the first Glass devices are coming out of the production line, Google has published MyGlass, a companion Android application for managing a Glass device, and the final specifications:

  • Display: 640 x 360p, the “equivalent of a 25 inch high definition screen from eight feet away”
  • Camera: Photo – 5MP, Video – 720p
  • Audio: bone conduction transducer
  • Connectivity: WiFi and Bluetooth
  • Storage: 16GB total, 12GB usable, synced with Google cloud
  • Battery: lasts one day for typical usage

Glass devices connect to the Internet though WiFi or via a Bluetooth-capable phone.

Rate this Article

Adoption
Style

BT