SlideShare a Scribd company logo
HAL APIs and Ember
Data
Cory Forsyth
@bantic
201 Created
Matthew BealeCory Forsyth
http://201-created.com/
What is HAL?
• Created by Mike Kelly in 2011
• Hypertext Application Language
• API Response Format Specification
What is HAL?
Hypermedia API
What is a Hypermedia API?
• Verb-oriented
• HATEOAS
• Client “drives” state changes taking actions
(aka following links) that the API provides
• JSON API is also a Hypermedia API
What is HAL?
• Optimized for developer on-boarding
• Built for machines, but human-friendly
HAL Example
{}
Simplest Possible Valid HAL Doc
HAL Example
GET /users/1
{
id: 1,
name: 'Cory'
}
Single resource
HAL Special Properties
• _embedded
• _links
• CURIEs
HAL Special Properties
• _embedded
• _links
• CURIEs
Embedded value(s)
HAL Special Properties
• _embedded
• _links
• CURIEs
Embedded value(s)
Links to related resources
HAL Special Properties
• _embedded
• _links
• CURIEs
Embedded value(s)
Links to related resources
Documentation “hints”
HAL Special Properties
• _embedded
• _links
• CURIEs
Embedded value(s) (optional)
Links to related resources (optional)
Documentation “hints” (optional)
HAL Example
GET /users
{
_embedded: {
users: [{
id: 1,
name: 'Cory'
}, {
id: 2,
name: 'Bob'
}]
}
}
Users collection
HAL Example
{
count: 2,
_embedded: {
users: [{
id: 1,
name: 'Cory'
}, {
id: 2,
name: 'Bob'
}]
}
}
Users collection
Info about the resource
collection. (Metadata)
HAL Example
{
id: 1,
name: 'Cory',
_links: {
self: { href: '/' },
pets: { href: '/users/1/pets'}
}
}
Single User Resource _links
HAL Example
{
id: 1,
name: 'Cory',
_links: {
self: { href: '/' },
pets: { href: '/users/1/pets'}
}
}
Single User Resource _links
Follow this link to get my pets
The HAL Model
Resources and Links
• Resources have
• links to URIs
• embedded
resources
• state (aka data)
• Links have
• Target URI
• Relation
name (“self”,
“pets”, etc)
• (Some other
properties)
The HAL Model
Resources and Links
HAL vs JSON API
• HAL
• Serialization
spec (only)
• Minimal
• Arbitrary
nesting
• “Discoverable”
• JSON API
• Serialization
and upload
• Comprehensive
• “Side-loading” /
Flat structure
HAL and JSON API
• HAL
• Has links concept
• Is a Hypermedia API
• JSON API
• Has links concept
• Is a Hypermedia API
HAL vs Ember Data
• Ember Data Adapter
• builds URLs
• uses serializer to
generate request
payloads
• uses serializer to map
response payloads to
model instances
• Ember Data Serializer
• Normalizes payload into
objects that can be
`push`-ed to the store
• Extracts single/array,
`push`-ing results into
store
• Extracts metadata
HAL vs Ember Data
• ED’s store has its own expected JSON format
• ED will use links if they are in its expected format
• ED has ‘meta’ concept, HAL does not
ember-data-hal-9000
• No adapter (ironic)
• Serializer restructures payloads from
HAL style to ember-data’s expected
format
• Un-nests _embedded values into side
loads
• HAL has no formal metadata concept
• hal-9000 uses a heuristic to derive
metadata
ember-data-hal-9000
Thanks to Aptible (they are hiring)
ember-data-hal-9000
• Restructure and un-nest _embeddeds
• override `normalize` to rewrite “_links” ->
“links”
• override `extractSingle`, `extractArray` to
un-nest _embedded values, replacing with
ids and sideloading
ember-data-hal-9000
{
user: {
id: 1,
name: 'Cory',
pet: 2
},
pets: [{
id: 2,
name: 'Fido'
}]
}
{
id: 1,
name: 'Cory',
_embedded: {
pet: {
id: 2,
name: 'Fido'
}
}
}
HAL Format Store Format
ember-data-hal-9000
• HAL has no formal concept of metadata,
• but it has collection resource properties
• hal-9000 presumes these are metadata
Metadata
ember-data-hal-9000
{
total: 2,
_embedded: [{
users: [{
id: 1,
name: 'Cory'
}]
}]
}
HAL Format
ember-data-hal-9000
{
total: 2,
_embedded: [{
users: [{
id: 1,
name: 'Cory'
}]
}]
}
HAL Format
store.metadataFor(‘user’).total
ember-data-hal-9000
{
id: 1,
name: 'Cory',
_links: {
pet: { href: '/users/1/pet' }
}
}
Link traversal
store.find('user', 1).then(function(user){
return user.get('pet');
});
ember-data-hal-9000
{
id: 1,
name: 'Cory',
_links: {
pet: { href: '/users/1/pet' }
}
}
Link traversal
store.find('user', 1).then(function(user){
return user.get('pet');
});
fetches /users/1/pet
Cory Forsyth
@bantic
• Slides: http://bit.ly/ember-data-hal-slides
• ember-data-hal-9000 Ember Data Adapter
• Hypermedia APIS JavasScript Jabber
• HAL Discuss Google Group
• Designing Hypermedia APIs (Youtube)
• HAL Spec @ Stateless
• HAL Primer
• Interview with Mike Kelly
• HAL Explorer
• HAL Spec @ IETF
• aptible.com
Links
Photo credits
http://stateless.co/hal_specification.html

More Related Content

What's hot

Apache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM AlternativeApache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM Alternative
Andrus Adamchik
 
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConDeep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
SPTechCon
 
APEX HROUG 2019 - Universal Theme: Tips and Tweaks
APEX HROUG 2019 - Universal Theme: Tips and TweaksAPEX HROUG 2019 - Universal Theme: Tips and Tweaks
APEX HROUG 2019 - Universal Theme: Tips and Tweaks
Marko Gorički
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
Yash Mody
 
Oracle Database Management REST API
Oracle Database Management REST APIOracle Database Management REST API
Oracle Database Management REST API
Jeff Smith
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate Overview
Brett Meyer
 
Orm and hibernate
Orm and hibernateOrm and hibernate
Orm and hibernate
s4al_com
 
Finding Love with MongoDB
Finding Love with MongoDBFinding Love with MongoDB
Finding Love with MongoDB
MongoDB
 
Java Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewJava Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief Overview
Craig Dickson
 
APEX Office Hours Interactive Grid Deep Dive
APEX Office Hours Interactive Grid Deep DiveAPEX Office Hours Interactive Grid Deep Dive
APEX Office Hours Interactive Grid Deep Dive
JohnSnyders
 
RestfulDesignRules
RestfulDesignRulesRestfulDesignRules
RestfulDesignRules
Michael De Courci
 
Java EE revisits design patterns
Java EE revisits design patterns Java EE revisits design patterns
Java EE revisits design patterns
Alex Theedom
 
Oracle REST Data Services: POUG Edition
Oracle REST Data Services: POUG EditionOracle REST Data Services: POUG Edition
Oracle REST Data Services: POUG Edition
Jeff Smith
 
Automating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePointAutomating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePoint
Talbott Crowell
 
Fluxible
FluxibleFluxible
Fluxible
Taylor Lovett
 
Introduction to Sightly and Sling Models
Introduction to Sightly and Sling ModelsIntroduction to Sightly and Sling Models
Introduction to Sightly and Sling Models
Stefano Celentano
 
Gab2015 azure search as a service
Gab2015 azure search as a serviceGab2015 azure search as a service
Gab2015 azure search as a service
Alexandre Marreiros
 
A Practical Guide To Hypermedia APIs - Philly.rb
A Practical Guide To Hypermedia APIs - Philly.rbA Practical Guide To Hypermedia APIs - Philly.rb
A Practical Guide To Hypermedia APIs - Philly.rb
SmartLogic
 
Building search app with ElasticSearch
Building search app with ElasticSearchBuilding search app with ElasticSearch
Building search app with ElasticSearch
Lukas Vlcek
 
EVOLVE'13 | Enhance | External Search | Matthias Wermund
EVOLVE'13 | Enhance | External Search | Matthias WermundEVOLVE'13 | Enhance | External Search | Matthias Wermund
EVOLVE'13 | Enhance | External Search | Matthias Wermund
Evolve The Adobe Digital Marketing Community
 

What's hot (20)

Apache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM AlternativeApache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM Alternative
 
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConDeep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
 
APEX HROUG 2019 - Universal Theme: Tips and Tweaks
APEX HROUG 2019 - Universal Theme: Tips and TweaksAPEX HROUG 2019 - Universal Theme: Tips and Tweaks
APEX HROUG 2019 - Universal Theme: Tips and Tweaks
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
 
Oracle Database Management REST API
Oracle Database Management REST APIOracle Database Management REST API
Oracle Database Management REST API
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate Overview
 
Orm and hibernate
Orm and hibernateOrm and hibernate
Orm and hibernate
 
Finding Love with MongoDB
Finding Love with MongoDBFinding Love with MongoDB
Finding Love with MongoDB
 
Java Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewJava Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief Overview
 
APEX Office Hours Interactive Grid Deep Dive
APEX Office Hours Interactive Grid Deep DiveAPEX Office Hours Interactive Grid Deep Dive
APEX Office Hours Interactive Grid Deep Dive
 
RestfulDesignRules
RestfulDesignRulesRestfulDesignRules
RestfulDesignRules
 
Java EE revisits design patterns
Java EE revisits design patterns Java EE revisits design patterns
Java EE revisits design patterns
 
Oracle REST Data Services: POUG Edition
Oracle REST Data Services: POUG EditionOracle REST Data Services: POUG Edition
Oracle REST Data Services: POUG Edition
 
Automating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePointAutomating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePoint
 
Fluxible
FluxibleFluxible
Fluxible
 
Introduction to Sightly and Sling Models
Introduction to Sightly and Sling ModelsIntroduction to Sightly and Sling Models
Introduction to Sightly and Sling Models
 
Gab2015 azure search as a service
Gab2015 azure search as a serviceGab2015 azure search as a service
Gab2015 azure search as a service
 
A Practical Guide To Hypermedia APIs - Philly.rb
A Practical Guide To Hypermedia APIs - Philly.rbA Practical Guide To Hypermedia APIs - Philly.rb
A Practical Guide To Hypermedia APIs - Philly.rb
 
Building search app with ElasticSearch
Building search app with ElasticSearchBuilding search app with ElasticSearch
Building search app with ElasticSearch
 
EVOLVE'13 | Enhance | External Search | Matthias Wermund
EVOLVE'13 | Enhance | External Search | Matthias WermundEVOLVE'13 | Enhance | External Search | Matthias Wermund
EVOLVE'13 | Enhance | External Search | Matthias Wermund
 

Similar to HAL APIs and Ember Data

Rest in practice
Rest in practiceRest in practice
Rest in practice
Ian Brennan
 
Building Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff StanoBuilding Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff Stano
Sencha
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
Antonio Peric-Mazar
 
Introduction to Restful Web Services
Introduction to Restful Web ServicesIntroduction to Restful Web Services
Introduction to Restful Web Services
weili_at_slideshare
 
Fhir dev days 2017 fhir profiling - overview and introduction v07
Fhir dev days 2017   fhir profiling - overview and introduction v07Fhir dev days 2017   fhir profiling - overview and introduction v07
Fhir dev days 2017 fhir profiling - overview and introduction v07
DevDays
 
Rest
RestRest
Building Self Documenting HTTP APIs with CQRS
Building Self Documenting HTTP APIs with CQRSBuilding Self Documenting HTTP APIs with CQRS
Building Self Documenting HTTP APIs with CQRS
Derek Comartin
 
A Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIsA Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIs
SmartLogic
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframework
Erhwen Kuo
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debate
Restlet
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
Jason Gerard
 
Resting on your laurels will get you powned
Resting on your laurels will get you pownedResting on your laurels will get you powned
Resting on your laurels will get you powned
Dinis Cruz
 
HDP Next: Governance
HDP Next: GovernanceHDP Next: Governance
HDP Next: Governance
DataWorks Summit
 
The Kasabi Information Marketplace
The Kasabi Information MarketplaceThe Kasabi Information Marketplace
The Kasabi Information Marketplace
Knud Möller
 
Harnessing Free Content with Web Service APIs
Harnessing Free Content with Web Service APIsHarnessing Free Content with Web Service APIs
Harnessing Free Content with Web Service APIs
ALATechSource
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swagger
Tony Tam
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
Hong-Jhih Lin
 
Solr + Hadoop: Interactive Search for Hadoop
Solr + Hadoop: Interactive Search for HadoopSolr + Hadoop: Interactive Search for Hadoop
Solr + Hadoop: Interactive Search for Hadoop
gregchanan
 
Mule soft RAML API Designing
Mule soft RAML API DesigningMule soft RAML API Designing
Mule soft RAML API Designing
Raja Reddy
 
Json api dos and dont's
Json api dos and dont'sJson api dos and dont's
Json api dos and dont's
Neven Rakonić
 

Similar to HAL APIs and Ember Data (20)

Rest in practice
Rest in practiceRest in practice
Rest in practice
 
Building Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff StanoBuilding Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff Stano
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Introduction to Restful Web Services
Introduction to Restful Web ServicesIntroduction to Restful Web Services
Introduction to Restful Web Services
 
Fhir dev days 2017 fhir profiling - overview and introduction v07
Fhir dev days 2017   fhir profiling - overview and introduction v07Fhir dev days 2017   fhir profiling - overview and introduction v07
Fhir dev days 2017 fhir profiling - overview and introduction v07
 
Rest
RestRest
Rest
 
Building Self Documenting HTTP APIs with CQRS
Building Self Documenting HTTP APIs with CQRSBuilding Self Documenting HTTP APIs with CQRS
Building Self Documenting HTTP APIs with CQRS
 
A Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIsA Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIs
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframework
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debate
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
Resting on your laurels will get you powned
Resting on your laurels will get you pownedResting on your laurels will get you powned
Resting on your laurels will get you powned
 
HDP Next: Governance
HDP Next: GovernanceHDP Next: Governance
HDP Next: Governance
 
The Kasabi Information Marketplace
The Kasabi Information MarketplaceThe Kasabi Information Marketplace
The Kasabi Information Marketplace
 
Harnessing Free Content with Web Service APIs
Harnessing Free Content with Web Service APIsHarnessing Free Content with Web Service APIs
Harnessing Free Content with Web Service APIs
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swagger
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
 
Solr + Hadoop: Interactive Search for Hadoop
Solr + Hadoop: Interactive Search for HadoopSolr + Hadoop: Interactive Search for Hadoop
Solr + Hadoop: Interactive Search for Hadoop
 
Mule soft RAML API Designing
Mule soft RAML API DesigningMule soft RAML API Designing
Mule soft RAML API Designing
 
Json api dos and dont's
Json api dos and dont'sJson api dos and dont's
Json api dos and dont's
 

More from Cory Forsyth

EmberFest Mobiledoc Demo Lightning Talk
EmberFest Mobiledoc Demo Lightning TalkEmberFest Mobiledoc Demo Lightning Talk
EmberFest Mobiledoc Demo Lightning Talk
Cory Forsyth
 
Making ember-wormhole work with Fastboot
Making ember-wormhole work with FastbootMaking ember-wormhole work with Fastboot
Making ember-wormhole work with Fastboot
Cory Forsyth
 
Chrome Extensions at Manhattan JS
Chrome Extensions at Manhattan JSChrome Extensions at Manhattan JS
Chrome Extensions at Manhattan JS
Cory Forsyth
 
OAuth 2.0 Misconceptions
OAuth 2.0 MisconceptionsOAuth 2.0 Misconceptions
OAuth 2.0 Misconceptions
Cory Forsyth
 
Ember Authentication and Authorization with Torii
Ember Authentication and Authorization with ToriiEmber Authentication and Authorization with Torii
Ember Authentication and Authorization with Torii
Cory Forsyth
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
Cory Forsyth
 
Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cli
Cory Forsyth
 
Stackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for EverybodyStackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for Everybody
Cory Forsyth
 
Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014
Cory Forsyth
 
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
Cory Forsyth
 
Torii: Ember.js Authentication Library
Torii: Ember.js Authentication LibraryTorii: Ember.js Authentication Library
Torii: Ember.js Authentication Library
Cory Forsyth
 
APIs: Internet for Robots
APIs: Internet for RobotsAPIs: Internet for Robots
APIs: Internet for Robots
Cory Forsyth
 

More from Cory Forsyth (12)

EmberFest Mobiledoc Demo Lightning Talk
EmberFest Mobiledoc Demo Lightning TalkEmberFest Mobiledoc Demo Lightning Talk
EmberFest Mobiledoc Demo Lightning Talk
 
Making ember-wormhole work with Fastboot
Making ember-wormhole work with FastbootMaking ember-wormhole work with Fastboot
Making ember-wormhole work with Fastboot
 
Chrome Extensions at Manhattan JS
Chrome Extensions at Manhattan JSChrome Extensions at Manhattan JS
Chrome Extensions at Manhattan JS
 
OAuth 2.0 Misconceptions
OAuth 2.0 MisconceptionsOAuth 2.0 Misconceptions
OAuth 2.0 Misconceptions
 
Ember Authentication and Authorization with Torii
Ember Authentication and Authorization with ToriiEmber Authentication and Authorization with Torii
Ember Authentication and Authorization with Torii
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
 
Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cli
 
Stackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for EverybodyStackup New Languages Talk: Ember is for Everybody
Stackup New Languages Talk: Ember is for Everybody
 
Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014
 
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
 
Torii: Ember.js Authentication Library
Torii: Ember.js Authentication LibraryTorii: Ember.js Authentication Library
Torii: Ember.js Authentication Library
 
APIs: Internet for Robots
APIs: Internet for RobotsAPIs: Internet for Robots
APIs: Internet for Robots
 

Recently uploaded

Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
APNIC
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
xjq03c34
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
rtunex8r
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
3a0sd7z3
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
Donato Onofri
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
APNIC
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
3a0sd7z3
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
davidjhones387
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
k4ncd0z
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
thezot
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
Tarandeep Singh
 

Recently uploaded (12)

Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
 

HAL APIs and Ember Data

  • 1. HAL APIs and Ember Data Cory Forsyth @bantic
  • 2. 201 Created Matthew BealeCory Forsyth http://201-created.com/
  • 3. What is HAL? • Created by Mike Kelly in 2011 • Hypertext Application Language • API Response Format Specification
  • 5. What is a Hypermedia API? • Verb-oriented • HATEOAS • Client “drives” state changes taking actions (aka following links) that the API provides • JSON API is also a Hypermedia API
  • 6. What is HAL? • Optimized for developer on-boarding • Built for machines, but human-friendly
  • 8. HAL Example GET /users/1 { id: 1, name: 'Cory' } Single resource
  • 9. HAL Special Properties • _embedded • _links • CURIEs
  • 10. HAL Special Properties • _embedded • _links • CURIEs Embedded value(s)
  • 11. HAL Special Properties • _embedded • _links • CURIEs Embedded value(s) Links to related resources
  • 12. HAL Special Properties • _embedded • _links • CURIEs Embedded value(s) Links to related resources Documentation “hints”
  • 13. HAL Special Properties • _embedded • _links • CURIEs Embedded value(s) (optional) Links to related resources (optional) Documentation “hints” (optional)
  • 14. HAL Example GET /users { _embedded: { users: [{ id: 1, name: 'Cory' }, { id: 2, name: 'Bob' }] } } Users collection
  • 15. HAL Example { count: 2, _embedded: { users: [{ id: 1, name: 'Cory' }, { id: 2, name: 'Bob' }] } } Users collection Info about the resource collection. (Metadata)
  • 16. HAL Example { id: 1, name: 'Cory', _links: { self: { href: '/' }, pets: { href: '/users/1/pets'} } } Single User Resource _links
  • 17. HAL Example { id: 1, name: 'Cory', _links: { self: { href: '/' }, pets: { href: '/users/1/pets'} } } Single User Resource _links Follow this link to get my pets
  • 18. The HAL Model Resources and Links • Resources have • links to URIs • embedded resources • state (aka data) • Links have • Target URI • Relation name (“self”, “pets”, etc) • (Some other properties)
  • 20. HAL vs JSON API • HAL • Serialization spec (only) • Minimal • Arbitrary nesting • “Discoverable” • JSON API • Serialization and upload • Comprehensive • “Side-loading” / Flat structure
  • 21. HAL and JSON API • HAL • Has links concept • Is a Hypermedia API • JSON API • Has links concept • Is a Hypermedia API
  • 22. HAL vs Ember Data • Ember Data Adapter • builds URLs • uses serializer to generate request payloads • uses serializer to map response payloads to model instances • Ember Data Serializer • Normalizes payload into objects that can be `push`-ed to the store • Extracts single/array, `push`-ing results into store • Extracts metadata
  • 23. HAL vs Ember Data • ED’s store has its own expected JSON format • ED will use links if they are in its expected format • ED has ‘meta’ concept, HAL does not
  • 24. ember-data-hal-9000 • No adapter (ironic) • Serializer restructures payloads from HAL style to ember-data’s expected format • Un-nests _embedded values into side loads • HAL has no formal metadata concept • hal-9000 uses a heuristic to derive metadata
  • 26. ember-data-hal-9000 • Restructure and un-nest _embeddeds • override `normalize` to rewrite “_links” -> “links” • override `extractSingle`, `extractArray` to un-nest _embedded values, replacing with ids and sideloading
  • 27. ember-data-hal-9000 { user: { id: 1, name: 'Cory', pet: 2 }, pets: [{ id: 2, name: 'Fido' }] } { id: 1, name: 'Cory', _embedded: { pet: { id: 2, name: 'Fido' } } } HAL Format Store Format
  • 28. ember-data-hal-9000 • HAL has no formal concept of metadata, • but it has collection resource properties • hal-9000 presumes these are metadata Metadata
  • 29. ember-data-hal-9000 { total: 2, _embedded: [{ users: [{ id: 1, name: 'Cory' }] }] } HAL Format
  • 30. ember-data-hal-9000 { total: 2, _embedded: [{ users: [{ id: 1, name: 'Cory' }] }] } HAL Format store.metadataFor(‘user’).total
  • 31. ember-data-hal-9000 { id: 1, name: 'Cory', _links: { pet: { href: '/users/1/pet' } } } Link traversal store.find('user', 1).then(function(user){ return user.get('pet'); });
  • 32. ember-data-hal-9000 { id: 1, name: 'Cory', _links: { pet: { href: '/users/1/pet' } } } Link traversal store.find('user', 1).then(function(user){ return user.get('pet'); }); fetches /users/1/pet
  • 33. Cory Forsyth @bantic • Slides: http://bit.ly/ember-data-hal-slides • ember-data-hal-9000 Ember Data Adapter • Hypermedia APIS JavasScript Jabber • HAL Discuss Google Group • Designing Hypermedia APIs (Youtube) • HAL Spec @ Stateless • HAL Primer • Interview with Mike Kelly • HAL Explorer • HAL Spec @ IETF • aptible.com Links Photo credits http://stateless.co/hal_specification.html