REST meets 
Semantic Web 
by Steve Speicher @sspeiche 
©Steve Speicher @sspeiche. All rights reserved. REST meets Semantic Web
Areas to explore… 
RESTperts 
Case Study 
Semantic 
What? 
BEvERages
Look at a real cases 
Case Study 
(show me) 
“Without data you’re just another person with 
an opinion” 
W. Edwards Deming
Case Study 
Problem: 
From some known issues, find out how 
long they have been open per assignee. 
Oh, based on GitHub issues.
GitHub Issues 
Case Study 
There’s an API for that… 
GET /repos/:owner/:repo/issues/:number
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}” 
}, 
}
Case Study 
if (val.state == "closed” && val.assignee.login == assignee) { 
computeCloseTime(assignee, val.closed_at, val.created_at); 
} 
Simple enough code, right?
Case Study
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” 
}, 
}
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!
Case Study
Case Study 
©Steve Speicher @sspeiche. All rights reserved. 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….
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” : ”steves@unicorns.org", 
”title": ”Steve S” 
}, 
} 
Ideal
Case Study 
This initial code sample could be the 
var issue = parseIssue(val); 
if (issue.status == “closed” && 
issue.assignee.login == assignee) { 
computeCloseTime(assignee, issue.closed, issue.created); 
} 
complex case too…
Case Study 
var issue = parseIssue(val); 
if (issue.closed && issue.assignee.login == assignee) { 
computeCloseTime(assignee, issue.closed, issue.created); 
} 
…and even simpler
PRACTICAL APPLICATIONS 
OF SEMANTICS IN RETAIL 
A YEAR OF EXPERIMENTATION 
Jay Myers, Best Buy @jaymyers
COMMON DATA FLOW INTO CMS/ PIM 
Data Source(s) PIM/ CMS 
with 
schema 
Accepted 
data 
Discarded 
data 
RDBMS
COMPLETE DATA + SEMANTICS = DISCOVERY 
+ +
CONVERSION 
11x 9x 5x 
“Stocking Stuffers” Valentine’s Day St Patrick’s Day 
* vs. standard site conversion
(web services) 
What is REST? 
Ask the… 
REST 
RESTafarians, RESTperts, …
REST 
(web services) 
Resource GET POST PUT DELETE 
Collection URI 
fetch create 
http://ex.com/resources 
element 
create / 
replace 
rm * 
Element URI 
http://ex.com/resources/item17 
fetch open create / 
replace 
rm
Create and add 
POST /container1 HTTP/1.1 
Host: example.org 
Content-length: 324 
Link: <http://schema.org/context.jsonld>; rel=“context” 
{ 
”@type" : ”http://schema.org/Product", 
”name" : ”White microwave", 
”productId" : ”w2134" 
} 
HTTP/1.1 201 CREATED 
Content-Location: http://example.org/container1/member4 
Response Request 
POST 
container1 
member1 
member2 
member3 
+member4 
http://example.org
Fetch updated collection 
GET /container1 HTTP/1.1 
Host: example.org 
Accept: application/ld+json, application/json, */*;q=0.1 
Request 
GET 
container1 
member1 
member2 
member3 
member4 
http://example.org 
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" ] 
} 
Response
Semantics 
(understanding) 
Semantics 
So I have some representation, now 
what?
hypermedia 
REST 
+ =
<a href=“/item47” type=“product”>Product A</a> 
or 
“productId” : “w2134” 
“name” : “Product B” 
REST 
What about the hypermedia?
Semantics 
Are we talking about the same thing? 
“productId” : “w2134” 
or 
“product” : “http://ex.com/resources/item47”
Semantics 
What are we talking about? 
“productId” : “w2134” 
or 
“@type” : “http://schema.org/Product” 
“isCatalog” : true 
or 
“@type” : “http://www.w3.org/ns/ldp#Container”
Did a small part of Roy T. Fielding die? 
What went wrong? 
Wrap it up
Discovery Docs 
Wrap it up 
URL templates - https://tools.ietf.org/html/rfc6570 
JSON-Home - http://tools.ietf.org/html/draft-nottingham-json-home-03 
stacker.io - http://petstore.swagger.wordnik.com/
© your company name. All rights reserved. Title of your presentation

REST meets Semantic Web

  • 1.
    REST meets SemanticWeb by Steve Speicher @sspeiche ©Steve Speicher @sspeiche. All rights reserved. REST meets Semantic Web
  • 2.
    Areas to explore… RESTperts Case Study Semantic What? BEvERages
  • 3.
    Look at areal cases Case Study (show me) “Without data you’re just another person with an opinion” W. Edwards Deming
  • 4.
    Case Study Problem: From some known issues, find out how long they have been open per assignee. Oh, based on GitHub issues.
  • 5.
    GitHub Issues CaseStudy There’s an API for that… GET /repos/:owner/:repo/issues/:number
  • 6.
    Case Study $curlhttps://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}” }, }
  • 7.
    Case Study if(val.state == "closed” && val.assignee.login == assignee) { computeCloseTime(assignee, val.closed_at, val.created_at); } Simple enough code, right?
  • 8.
  • 9.
    Case Study $curlhttps://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” }, }
  • 10.
    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!
  • 11.
  • 12.
    Case Study ©SteveSpeicher @sspeiche. All rights reserved. REST meets Semantic Web
  • 13.
    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….
  • 14.
    Case Study $curlhttps://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” : ”steves@unicorns.org", ”title": ”Steve S” }, } Ideal
  • 15.
    Case Study Thisinitial code sample could be the var issue = parseIssue(val); if (issue.status == “closed” && issue.assignee.login == assignee) { computeCloseTime(assignee, issue.closed, issue.created); } complex case too…
  • 16.
    Case Study varissue = parseIssue(val); if (issue.closed && issue.assignee.login == assignee) { computeCloseTime(assignee, issue.closed, issue.created); } …and even simpler
  • 17.
    PRACTICAL APPLICATIONS OFSEMANTICS IN RETAIL A YEAR OF EXPERIMENTATION Jay Myers, Best Buy @jaymyers
  • 18.
    COMMON DATA FLOWINTO CMS/ PIM Data Source(s) PIM/ CMS with schema Accepted data Discarded data RDBMS
  • 19.
    COMPLETE DATA +SEMANTICS = DISCOVERY + +
  • 20.
    CONVERSION 11x 9x5x “Stocking Stuffers” Valentine’s Day St Patrick’s Day * vs. standard site conversion
  • 21.
    (web services) Whatis REST? Ask the… REST RESTafarians, RESTperts, …
  • 22.
    REST (web services) Resource GET POST PUT DELETE Collection URI fetch create http://ex.com/resources element create / replace rm * Element URI http://ex.com/resources/item17 fetch open create / replace rm
  • 23.
    Create and add POST /container1 HTTP/1.1 Host: example.org Content-length: 324 Link: <http://schema.org/context.jsonld>; rel=“context” { ”@type" : ”http://schema.org/Product", ”name" : ”White microwave", ”productId" : ”w2134" } HTTP/1.1 201 CREATED Content-Location: http://example.org/container1/member4 Response Request POST container1 member1 member2 member3 +member4 http://example.org
  • 24.
    Fetch updated collection GET /container1 HTTP/1.1 Host: example.org Accept: application/ld+json, application/json, */*;q=0.1 Request GET container1 member1 member2 member3 member4 http://example.org 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" ] } Response
  • 25.
    Semantics (understanding) Semantics So I have some representation, now what?
  • 26.
  • 27.
    <a href=“/item47” type=“product”>ProductA</a> or “productId” : “w2134” “name” : “Product B” REST What about the hypermedia?
  • 28.
    Semantics Are wetalking about the same thing? “productId” : “w2134” or “product” : “http://ex.com/resources/item47”
  • 29.
    Semantics What arewe talking about? “productId” : “w2134” or “@type” : “http://schema.org/Product” “isCatalog” : true or “@type” : “http://www.w3.org/ns/ldp#Container”
  • 30.
    Did a smallpart of Roy T. Fielding die? What went wrong? Wrap it up
  • 31.
    Discovery Docs Wrapit up URL templates - https://tools.ietf.org/html/rfc6570 JSON-Home - http://tools.ietf.org/html/draft-nottingham-json-home-03 stacker.io - http://petstore.swagger.wordnik.com/
  • 32.
    © your companyname. All rights reserved. Title of your presentation

Editor's Notes

  • #17 Inter status “closed” by the existence of the issue.closed property having a value
  • #19 Source: http://www.slideshare.net/jaymmyers/practical-applications-of-semantic-web-in-retail-semtech-2014