Mirror API introduction

Post on 13-Jun-2015

1.501 views 3 download

Tags:

description

Introduction to the Mirror API basics for #hack4wear at Campus London on 30th Nov 2013

Transcript of Mirror API introduction

Mirror PIMirrorintroduction

slideshare.net/

linkedin.com/in/

twitter.com/

google.com/+} radeksimko

How?

Insert a new cardPOST /mirror/v1/timeline HTTP/1.1Host: www.googleapis.comAuthorization: Bearer auth tokenContent-Type: application/jsonContent-Length: 26

{ "text": "Hello world" }

Card with HTMLPOST /mirror/v1/timeline HTTP/1.1Host: www.googleapis.comAuthorization: Bearer auth tokenContent-Type: application/jsonContent-Length: 26

{ "html": "<article><section><p>This <em>quotation</em>is <strong>strong</strong></p></section></article>" }

Updating an existing cardPUT /mirror/v1/timeline/{id} HTTP/1.1Host: www.googleapis.comAuthorization: Bearer auth tokenContent-Type: application/json

{ "text": "Hello world", "location": { ... } "menuItems": [ { "action": "NAVIGATE" } ]}

Updating an existing cardPATCH /mirror/v1/timeline/{id} HTTP/1.1Host: www.googleapis.comAuthorization: Bearer auth tokenContent-Type: application/json

{ "text": "Hello world" }

Deleting a cardDELETE /mirror/v1/timeline/{id} HTTP/1.1Host: www.googleapis.comAuthorization: Bearer auth token

Menu ItemsPOST /mirror/v1/timeline HTTP/1.1Host: www.googleapis.comAuthorization: Bearer auth tokenContent-Type: application/json

{ "text": "Lorem ipsum dolor sit amet.", "speakableText": "Some boring sample words", "menuItems": [ { "action": "READ_ALOUD" }, { "action": "TOGGLE_PINNED" }, ]}

Subscriptions APIWhen a user selects a menu item

When a user shares content with a contact

The user's location, every 10 mins

Subscribe to a user's locationPOST /mirror/v1/subscriptions HTTP/1.1Authorization: Bearer auth tokenContent-Type: application/jsonContent-Length: length

{ "collection": "location", "operation": [ "UPDATE" ], "callbackUrl": "https://example.com/callback"}

Location APIGET /mirror/v1/locations HTTP/1.1Authorization: Bearer auth tokenContent-Type: application/jsonContent-Length: length

{ "id": "latest"}

Insert a new contact with callbackPOST /mirror/v1/contacts HTTP/1.1Authorization: Bearer auth tokenContent-Type: application/jsonContent-Length: length

{ "id": "instagram", "displayName": "Instagram", "acceptTypes": [ "image/*" ], "imageUrls": [ "instagram.jpg" ]}

When user shares a picturePOST /mirror/v1/subscriptions HTTP/1.1Authorization: Bearer auth tokenContent-Type: application/jsonContent-Length: length

{ "collection": "timeline", "operation": [ "UPDATE" ], "callbackUrl": "https://example.com/callback"}

When user shares a picture{ "collection": "timeline", "itemId": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg", "operation": "UPDATE", "userActions": [ { "type": "SHARE" } ]}

When user shares a picture{ "id": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg", "attachments": [ { "contentType": "image/jpeg", "id": "<ATTACHMENT_ID>" } ], "recipients": [ { "kind": "glass#contact", "source": "api:<SERVICE_ID>", "id": "<CONTACT_ID>", "displayName": "<CONTACT_DISPLAY_NAME>", "imageUrls": [ "<CONTACT_ICON_URL>" ] } ]}

GuidelinesDesign for Glass

Keep it timely and relevant

Do not get in the way (CNN, Twitter, GMail)

Avoid the unexpected (time, frequency, location)

Thanks, stay in touchslideshare.net/

linkedin.com/in/

twitter.com/

google.com/+} radeksimko