• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Intro to Hypermedia APIs

Intro to Hypermedia APIs



An introduction to Hypermedia APIs from software developer Eric Oestrich.

An introduction to Hypermedia APIs from software developer Eric Oestrich.



Total Views
Views on SlideShare
Embed Views



1 Embed 1

http://www.hanrss.com 1


Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Intro to Hypermedia APIs Intro to Hypermedia APIs Presentation Transcript

    • Introduction toHypermedia APIs Eric Oestrich @ericoestrich oestri.ch smartlogicsolutions.com
    • What is a Hypermedia API?
    • RESTREpresentational State Transfer
    • Relies Heavily on HTTP● Methods and URI● Media Types● Client Server
    • Relies Heavily on HTTP (Cont)● Stateless● Caching● Uniform Interface (HATEOAS)
    • Methods and URIs
    • Five RoutesGET /ordersPOST /ordersGET /orders/:idPUT /orders/:idDELETE /orders/:id
    • GET /orders List of orders
    • POST /orders Create an order
    • GET /orders/:id View a single order
    • PUT /orders/:idReplace or create an order
    • DELETE /orders/:id Delete an order
    • A bit about HTTP Verbs
    • GETRetrieve a resource
    • POSTMost generic
    • PUTReplace or Create Not partial
    • DELETEDelete a resource
    • PATCHUpdate partially Must be a diff
    • Media Types
    • Formats● JSON● XML● XHTML
    • Setting the Media Type● Accept Headers● Rails way - .:format
    • Representational based Models != Representations
    • Uniform Interface
    • Uniform Interface● Identification of resources● Manipulation of resources via representations● Self descriptive messages● Hypermedia as the engine of application state
    • Identification of resources
    • Manipulation of resources via representations
    • Self descriptive messages Statelessness
    • Hypermedia as the engine of application state HATEOAS
    • Clients should not know how to build routes
    • Enter HALJSON cannot describe a link
    • HAL is a media type fordefining links in JSON application/hal+json
    • The Goal GET /
    • Great, now I know what a Hypermedia API is.
    • How do I make one?
    • Rails + Lots of Gems Also monkey patching
    • Gems● ActiveModel::Serializer● RspecApiDocumentation● Raddocs● A few other handy ones
    • $ rails new hypermedia_api --skip-test-unit
    • $ vim Gemfilegem raddocsgem active_model_serializers
    • $ vim Gemfilegroup :test, :development do gem rspec-rails gem rspec_api_documentationend
    • Get rspec set up
    • Create our firstacceptance test
    • Generate models, index action, serializers
    • Show
    • Create
    • Update
    • Delete
    • Setup HALLet the monkey patching begin
    • Were missingsomething...
    • $ curl http://localhost:3000/ ""
    • Root Resource
    • Questions? Eric Oestrich @ericoestrich oestri.chsmartlogicsolutions.com