32
REST meets Semantic Web by Steve Speicher @sspeiche ©Steve Speicher @sspeiche. All rights reserved. REST meets Semantic Web

REST meets Semantic Web

Embed Size (px)

DESCRIPTION

Charts from 10/8/2014 RTP meetup

Citation preview

Page 1: REST meets Semantic Web

REST meets Semantic Web

REST meets Semantic Webby Steve Speicher @sspeiche

©Steve Speicher @sspeiche. All rights reserved.

Page 2: REST meets Semantic Web

Areas to explore…

RESTperts

Semantic What?

Case Study

BEvERages

Page 3: REST meets Semantic Web

Look at a real cases

“Without data you’re just another person with an opinion”

W. Edwards Deming

Case Study(show me)

Page 4: REST meets Semantic Web

Problem:From some known issues, find out

how long they have been open per assignee.

Case Study

Oh, based on GitHub issues.

Page 5: REST meets Semantic Web

GitHub IssuesThere’s an API for that…

Case Study

GET /repos/:owner/:repo/issues/:number

Page 6: REST meets Semantic Web

Case Study

$curl https://api.github.com/repos/w3c/ldp-testsuite/issues/17 { "created_at": "2014-05-27T20:06:49Z",  "updated_at": "2014-06-30T01:37:00Z",  "closed_at": "2014-06-30T01:37:00Z",  "state": "closed",  "assignee": {     "login": "sspeiche",     "id": 727196,     "avatar_url": "https://avatars.githubusercontent.com/u/727196?v=2",     "url": "https://api.github.com/users/sspeiche",     "followers_url": "https://api.github.com/users/sspeiche/followers",     "following_url": "https://api.github.com/users/sspeiche/following{/other_user}",     "gists_url": "https://api.github.com/users/sspeiche/gists{/gist_id}”  },}

Page 7: REST meets Semantic Web

Case Study

if (val.state == "closed” && val.assignee.login == assignee) { computeCloseTime(assignee, val.closed_at, val.created_at);}

Simple enough code, right?

Page 8: REST meets Semantic Web

Case Study

Page 9: REST meets Semantic Web

Case Study

$curl https://issues.apache.org/jira/rest/api/2/issue/IO-147

{ "created": "2007-12-18T13:04:55.320+0000”, "updated": "2008-08-22T07:36:50.877+0000", "resolutiondate": "2008-01-04T12:32:51.403+0000”, "customfield_12310220": "2007-12-18 18:19:12.648", "status": { "self": "https://issues.apache.org/jira/rest/api/2/status/6", "name": "Closed", "id": "6", }, "assignee": { "self": "https://issues.apache.org/jira/rest/api/2/user?username=steves", "name": ”steves", "emailAddress": ”steves at apache dot org", "displayName": ”Steve S” },}

Page 10: REST meets Semantic Web

Case Study

if (val.state == "closed” && val.assignee.login == assignee) { computeCloseTime(assignee, val.closed_at, val.created_at);} else if (val.status.name == "Closed” && val.assignee.name == assignee) { computeCloseTime(assignee, val.resolutiondate, val.created);}

Code becomes this….

…not so simple anymore, but wait!

Page 11: REST meets Semantic Web

Case Study

Page 12: REST meets Semantic Web

Case Study

©Steve Speicher @sspeiche. All rights reserved.

REST meets Semantic Web

Page 13: REST meets Semantic Web

Case Study

if (val.state == "closed” && val.assignee.login == assignee) { computeCloseTime(assignee, val.closed_at, val.created_at);} else if (val.status.name == "Closed” && val.assignee.name == assignee) { computeCloseTime(assignee, val.resolutiondate, val.created);} else if (val.issueState != “Opened” && val.owner.login.id == assignee) { computeCloseTime(assignee, convertDateTime(val.end.date, val.end.time), convertDateTime(val.start.date, val.start.time));} else if (val.status != “Opened” && val.status != “InProgress” && val.status != “InReview” && matchAssignee(val.assignee.mbox, assignee)) { computeCloseTime(assignee, val.lastUpdated, val.creationDate);}

THEN code becomes this….

Page 14: REST meets Semantic Web

Case Study

$curl https://magical.unicorns.org/nonissue4

Link: </issue.jsonld>; rel=“context”

{ "created": "2008-08-18T13:04:55.320+0000”, "updated": "2008-09-04T12:32:51.403+0000", ”closed” : "2008-09-04T12:32:51.403+0000”, “status” : “closed”, "assignee": { ”@id” : "https://stevespeicher.me", ”login” : ”sspeiche", ”mbox” : ”[email protected]", ”title": ”Steve S” },}

Ideal

Page 15: REST meets Semantic Web

Case Study

var issue = parseIssue(val);if (issue.status == “closed” && issue.assignee.login == assignee) { computeCloseTime(assignee, issue.closed, issue.created);}

This initial code sample could be the complex case too…

Page 16: REST meets Semantic Web

Case Study

var issue = parseIssue(val);if (issue.closed && issue.assignee.login == assignee) { computeCloseTime(assignee, issue.closed, issue.created);}

…and even simpler

Page 17: REST meets Semantic Web

PRACTICAL APPLICATIONS OF SEMANTICS IN RETAILA YEAR OF EXPERIMENTATIONJay Myers, Best Buy @jaymyers

Borrowed From

Page 18: REST meets Semantic Web

COMMON DATA FLOW INTO CMS/ PIM

Data Source(s) PIM/ CMSwith

schema

Accepted data

Discardeddata

RDBMS

Page 19: REST meets Semantic Web

COMPLETE DATA + SEMANTICS = DISCOVERY

+ +

Page 20: REST meets Semantic Web

CONVERSION

11x 5x9x

* vs. standard site conversion

“Stocking Stuffers” Valentine’s Day St Patrick’s Day

Page 21: REST meets Semantic Web

What is REST?Ask the…

RESTafarians, RESTperts, …

REST(web services)

Page 22: REST meets Semantic Web

REST(web

services)

Resource GET POST PUT DELETE

Collection URIhttp://ex.com/resources

fetch create element

create / replace

rm *

Element URIhttp://ex.com/resources/item17

fetch open create / replace

rm

Page 23: REST meets Semantic Web

HTTP/1.1 201 CREATEDContent-Location: http://example.org/container1/member4

Create and addPOST /container1 HTTP/1.1Host: example.orgContent-length: 324Link: <http://schema.org/context.jsonld>; rel=“context”

{ ”@type" : ”http://schema.org/Product", ”name" : ”White microwave", ”productId" : ”w2134"}

Request

Resp

onse

http://example.org

container1

member1

member2

member3

+member4

POST

Page 24: REST meets Semantic Web

Fetch updated collectionGET /container1 HTTP/1.1Host: example.orgAccept: application/ld+json, application/json, */*;q=0.1

Reques

t

http://example.org

container1

member1

member2

member3

member4

GET

Removed HTTP headers to save some space

Link: </cat.jsonld>; rel=“context”

{ "@id" : "http://example.org/container1", "@type" : ”http://www.w3c.org/ns/ldp#Container", "title" : ”Product catalog", "member" : [ "member2", "member1", "member3", "member4" ]}R

esp

onse

Page 25: REST meets Semantic Web

SemanticsSo I have some representation, now what?

Semantics

(understanding)

Page 26: REST meets Semantic Web

hypermediaREST

+ =

Page 27: REST meets Semantic Web

<a href=“/item47” type=“product”>Product A</a>

or

“productId” : “w2134” “name” : “Product B”

REST

What about the hypermedia?

Page 28: REST meets Semantic Web

Semantics

“productId” : “w2134”

or

“product” : “http://ex.com/resources/item47”

Are we talking about the same thing?

Page 29: REST meets Semantic Web

Semantics

“productId” : “w2134”or“@type” : “http://schema.org/Product”

What are we talking about?

“isCatalog” : trueor“@type” : “http://www.w3.org/ns/ldp#Container”

Page 30: REST meets Semantic Web

What went wrong?

Did a small part of Roy T. Fielding die?

Wrap it up

Page 31: REST meets Semantic Web

Discovery DocsURL templates - https://tools.ietf.org/html/rfc6570JSON-Home - http://tools.ietf.org/html/draft-nottingham-json-home-03stacker.io - http://petstore.swagger.wordnik.com/

Wrap it up

Page 32: REST meets Semantic Web

© your company name. All rights reserved. Title of your presentation

http://w3.org/TR/ldp

W3C Linked Data Platform