Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hypermedia APIs & Self-Building Apps

94cb827736e36e0f6343e9640e72fec7?s=47 vlucas
June 09, 2012

Hypermedia APIs & Self-Building Apps

What if your application had all of the information it needed from your REST API to build itself? This session will use an example RESTful Hypermedia API running locally together with a live running custom-built mobile application to demonstrate how to automate building parts of a mobile application UI from a RESTful API response alone. We will then explore techniques to customize and fine-tune the UI while still automating most of the work from the API.



June 09, 2012


  1. Vance Lucas • Co-Founder, Brightbit http://brightb.it Hypermedia APIs & Self-Building

  2. Who are You? • Vance Lucas • http://vancelucas.com • @vlucas

    (for heckling) • Brightbit • http://brightb.it • Design, Development & Consulting for web apps, mobile apps and APIs
  3. What is a REST API? Hypermedia API?

  4. Developed by Leonard Richardson http://martinfowler.com/articles/richardsonMaturityModel.html

  5. “Level 3” is a pre- condition of REST Roy T.

    Fielding http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
  6. You must have hypermedia controls in your API to call

    it REST
  7. “A REST API should be entered with no prior knowledge

    beyond the initial URI (bookmark) and set of standardized media types that are appropriate for the intended audience (i.e., expected to be understood by any client that might use the API). From that point on, all application state transitions must be driven by client selection of server-provided choices that are present in the received representations or implied by the user’s manipulation of those representations.” Roy T. Fielding http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
  8. What are these “hypermedia controls”?

  9. Two Key Things

  10. Links

  11. Forms

  12. But you can’t make forms in an API! Whhaaaaa!

  13. You Can. Kind of...

  14. JSON Schema http://tools.ietf.org/html/draft-zyp-json-schema-03

  15. JSON Schema { "description":"A person", "type":"object", "properties":{ "name":{"type":"string"}, "age" :{

    "type":"integer", "maximum":125 } } }
  16. URI Templates RFC 6570 http://tools.ietf.org/html/rfc6570

  17. URI Templates http://uri.com/~{username}/ #-> http://uri.com/~fred/ http://uri.com/dictionary/{term:1}/{term} #-> http://uri.com/dictionary/c/cat http://uri.com/search{?q,lang} #->

  18. HAL Spec (Unofficial) http://stateless.co/hal_specification.html

  19. HAL Specification { "_links": { "self": { "href": "/orders" },

    "next": { "href": "/orders?page=2" }, "search": { "href": "/orders?id={order_id}" } }, "_embedded": { "order": [ { "_links": { "self": { "href": "/orders/123" }, "customer": { "href": "/u/bob", "title": "Bob" } }, "total": 30.00, "currency": "USD", "status": "shipped", "placed": "2011-01-16", } ] } }
  20. Link “rel” Types http://www.iana.org/assignments/link-relations/link- relations.xml

  21. No official spec for linking or describing resources for JSON

    or XML APIs
  22. Too Boring; Didn’t Listen: Link and describe resources however you

    want, but be consistent.
  23. DEMO TIME! App: https://github.com/vlucas/brightbudget-app API: https://github.com/vlucas/brightbudget-web

  24. Questions? Rate this talk: https://joind.in/6205