SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Apache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM AlternativeApache Cayenne: a Java ORM Alternative
Apache Cayenne: a Java ORM AlternativeAndrus 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 - SPTechConSPTechCon
 
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 TweaksMarko 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 JAVAYash Mody
 
Oracle Database Management REST API
Oracle Database Management REST APIOracle Database Management REST API
Oracle Database Management REST APIJeff Smith
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewBrett Meyer
 
Orm and hibernate
Orm and hibernateOrm and hibernate
Orm and hibernates4al_com
 
Finding Love with MongoDB
Finding Love with MongoDBFinding Love with MongoDB
Finding Love with MongoDBMongoDB
 
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 OverviewCraig 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 DiveJohnSnyders
 
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 EditionJeff 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 SharePointTalbott Crowell
 
Introduction to Sightly and Sling Models
Introduction to Sightly and Sling ModelsIntroduction to Sightly and Sling Models
Introduction to Sightly and Sling ModelsStefano Celentano
 
Gab2015 azure search as a service
Gab2015 azure search as a serviceGab2015 azure search as a service
Gab2015 azure search as a serviceAlexandre 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.rbSmartLogic
 
Building search app with ElasticSearch
Building search app with ElasticSearchBuilding search app with ElasticSearch
Building search app with ElasticSearchLukas Vlcek
 

Tendances (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
 

Similaire à HAL APIs and Ember Data

Rest in practice
Rest in practiceRest in practice
Rest in practiceIan 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 StanoSencha
 
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 PlatformAntonio Peric-Mazar
 
Introduction to Restful Web Services
Introduction to Restful Web ServicesIntroduction to Restful Web Services
Introduction to Restful Web Servicesweili_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 v07DevDays
 
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 CQRSDerek Comartin
 
A Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIsA Practical Guide to Hypermedia APIs
A Practical Guide to Hypermedia APIsSmartLogic
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframeworkErhwen 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 debateRestlet
 
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 pownedDinis Cruz
 
The Kasabi Information Marketplace
The Kasabi Information MarketplaceThe Kasabi Information Marketplace
The Kasabi Information MarketplaceKnud 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 APIsALATechSource
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swaggerTony Tam
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using SwaggerHong-Jhih Lin
 
Solr + Hadoop: Interactive Search for Hadoop
Solr + Hadoop: Interactive Search for HadoopSolr + Hadoop: Interactive Search for Hadoop
Solr + Hadoop: Interactive Search for Hadoopgregchanan
 
Mule soft RAML API Designing
Mule soft RAML API DesigningMule soft RAML API Designing
Mule soft RAML API DesigningRaja Reddy
 
Json api dos and dont's
Json api dos and dont'sJson api dos and dont's
Json api dos and dont'sNeven Rakonić
 

Similaire à 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
 

Plus de Cory Forsyth

EmberFest Mobiledoc Demo Lightning Talk
EmberFest Mobiledoc Demo Lightning TalkEmberFest Mobiledoc Demo Lightning Talk
EmberFest Mobiledoc Demo Lightning TalkCory Forsyth
 
Making ember-wormhole work with Fastboot
Making ember-wormhole work with FastbootMaking ember-wormhole work with Fastboot
Making ember-wormhole work with FastbootCory Forsyth
 
Chrome Extensions at Manhattan JS
Chrome Extensions at Manhattan JSChrome Extensions at Manhattan JS
Chrome Extensions at Manhattan JSCory Forsyth
 
OAuth 2.0 Misconceptions
OAuth 2.0 MisconceptionsOAuth 2.0 Misconceptions
OAuth 2.0 MisconceptionsCory Forsyth
 
Ember Authentication and Authorization with Torii
Ember Authentication and Authorization with ToriiEmber Authentication and Authorization with Torii
Ember Authentication and Authorization with ToriiCory 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 ComeCory Forsyth
 
Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cliCory 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 EverybodyCory Forsyth
 
Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014Microsoft tech talk march 28 2014
Microsoft tech talk march 28 2014Cory 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.0Cory Forsyth
 
Torii: Ember.js Authentication Library
Torii: Ember.js Authentication LibraryTorii: Ember.js Authentication Library
Torii: Ember.js Authentication LibraryCory Forsyth
 
APIs: Internet for Robots
APIs: Internet for RobotsAPIs: Internet for Robots
APIs: Internet for RobotsCory Forsyth
 

Plus de 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
 

Dernier

Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New OrleansElevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleanscorenetworkseo
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Excelmac1
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
Intellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxIntellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxBipin Adhikari
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 

Dernier (20)

Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New OrleansElevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleans
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Intellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptxIntellectual property rightsand its types.pptx
Intellectual property rightsand its types.pptx
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 

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