The REST And Then Some

Social, mobile, and cloud security specialist at Nordic APIs
Nov. 7, 2016
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
The REST And Then Some
1 of 59

More Related Content

What's hot

REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterSachin G Kulkarni
Exposing Salesforce REST Services Using SwaggerExposing Salesforce REST Services Using Swagger
Exposing Salesforce REST Services Using SwaggerSalesforce Developers
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best PracticesTricode (part of Dept)
RESTful API Design FundamentalsRESTful API Design Fundamentals
RESTful API Design FundamentalsHüseyin BABAL
Designing and Running a GraphQL APIDesigning and Running a GraphQL API
Designing and Running a GraphQL APIAtlassian
API for BeginnersAPI for Beginners
API for BeginnersGustavo De Vita

Viewers also liked

Operational API design anti-patterns (Jason Harmon)Operational API design anti-patterns (Jason Harmon)
Operational API design anti-patterns (Jason Harmon)Nordic APIs
Don't roll your own HTTP serverDon't roll your own HTTP server
Don't roll your own HTTP serverNordic APIs
Criticality of identityCriticality of identity
Criticality of identityNordic APIs
Ser padres-coca colaSer padres-coca cola
Ser padres-coca colaMónica Lizeth Muñoz Flores
My Documents for NG SAMy Documents for NG SA
My Documents for NG SAMuhammad Ashfaq Hanif
Corso sicurezza SCUOLA FREUD Corso sicurezza SCUOLA FREUD
Corso sicurezza SCUOLA FREUD DANIELE NAPPO

Viewers also liked(20)

Similar to The REST And Then Some

REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011Alessandro Nadalin
 Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data... Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data...
Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data...Big Data Spain
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTPMykhailo Kolesnyk
REST and Resource Oriented Architecture - okcDG March 2008REST and Resource Oriented Architecture - okcDG March 2008
REST and Resource Oriented Architecture - okcDG March 2008Ryan Hoegg
Design Hypermedia APIsDesign Hypermedia APIs
Design Hypermedia APIsGustaf Nilsson Kotte
Api Design and More (Friday Training at Itnig)Api Design and More (Friday Training at Itnig)
Api Design and More (Friday Training at Itnig)itnig

More from Nordic APIs

Lessons Learned in Running an API-Centric SaaSLessons Learned in Running an API-Centric SaaS
Lessons Learned in Running an API-Centric SaaSNordic APIs
API Products: Who, What, Where, When, Why, and How?API Products: Who, What, Where, When, Why, and How?
API Products: Who, What, Where, When, Why, and How?Nordic APIs
OAuth Claims Ontology: Using Claims in OAuth and How They Relate to ScopesOAuth Claims Ontology: Using Claims in OAuth and How They Relate to Scopes
OAuth Claims Ontology: Using Claims in OAuth and How They Relate to ScopesNordic APIs
X-Road – Open Source Data Exchange LayerX-Road – Open Source Data Exchange Layer
X-Road – Open Source Data Exchange LayerNordic APIs
Taming Feral Systems With APIs in Region Östergötland’s Digitalisation PlatformTaming Feral Systems With APIs in Region Östergötland’s Digitalisation Platform
Taming Feral Systems With APIs in Region Östergötland’s Digitalisation PlatformNordic APIs
Mining API Traffic MetadataMining API Traffic Metadata
Mining API Traffic MetadataNordic APIs

Recently uploaded

Die ultimative Anleitung für HCL Nomad Web AdministratorenDie ultimative Anleitung für HCL Nomad Web Administratoren
Die ultimative Anleitung für HCL Nomad Web Administratorenpanagenda
Knowledge graph use cases in natural language generationKnowledge graph use cases in natural language generation
Knowledge graph use cases in natural language generationElena Simperl
Advancing Equity and Inclusion for Deaf Students in Higher EducationAdvancing Equity and Inclusion for Deaf Students in Higher Education
Advancing Equity and Inclusion for Deaf Students in Higher Education3Play Media
How to use the Cataloguing Code Ethics at your day job : a hands-on workshop ...How to use the Cataloguing Code Ethics at your day job : a hands-on workshop ...
How to use the Cataloguing Code Ethics at your day job : a hands-on workshop ...CILIP MDG
Elevate Your Enterprise with FME 23.1Elevate Your Enterprise with FME 23.1
Elevate Your Enterprise with FME 23.1Safe Software
Enterprise Application and Data Protection on AWS with Amazon FSx for NetApp ...Enterprise Application and Data Protection on AWS with Amazon FSx for NetApp ...
Enterprise Application and Data Protection on AWS with Amazon FSx for NetApp ...LilyJang3

Recently uploaded(20)

The REST And Then Some

Editor's Notes

  1. Hello! Thank you all for coming. I'm going to talk a bit about REST and hypermedia today.
  2. I’m Asbjørn Ulsberg, Business Architect for Web, API design and interfaces. In PayEx.
  3. Now that we have looked a bit at what REST is not, let's try to figure out what it is.
  4. The Argentinian author Jorge Luis Borges. (Horxe Luis Borxes) Started thinking about hypertext concepts in the 1930’s 1941: The Garden of Forking Paths: The first black on white reference to hypertext. About the Chinese Doctor Yu Tsun, a former professor of English, now a German spy in England during World War 1. Tsun can take multiple possible actions, but regardless of what actions he takes, he will always end up being arrested by Captain Richard Madden. “The Library of Babel” and ”The Book of Sands” expands on the hypertext ideas.
  5. The same concept as The Garden of Forking Paths can be found in modern RPG-style games like Bioshock Infinite and Fallout 3, where each decision forks the story in a new direction.
  6. 1963: Ted Nelson coined the terms 'hypertext' and 'hypermedia' in a model he developed for creating and using linked content (first published reference 1965). 1967: worked with Andries van Dam to develop the Hypertext Editing System (text editing) at Brown University.
  7. In December 1968, the first public demonstration of a hypertext interface was performed by Douglas Engelbart oN-Line System or more commonly, NLS. "The Mother of All Demos”: Mouse pointer, hypertext editing, word processing, e-mail and a windowing environment. Word processing was born Many of Engelbart's team members went on to start the Palo Alto Research Center, known as Xerox PARC, in 1971: http://www.thocp.net/biographies/engelbart_douglas.html
  8. In 1987, Bill Atkinson at Apple Computer created HyperCard. It was a successor to lots and lots of things: Xcode before Xcode (programming environment) AppleScript before AppleScript (near-english programming language) Java before Java (JIT) Interface Builder before Interface Builder, which was Visual Basic before Visual Basic. Flash before Flash (animations) FileMaker before FileMaker (build databases) Built-in debugger ”Fix and continue” before “fix and continue”
  9. Tim Berners-Lee 1989: Develops "WorldWideWeb” at CERN, on a NeXTStep computer. 1991: HTTP 0.9, Formal description, no status codes, GET only. 1996: HTTP 1.0, RFC 1945 1997: HTTP 1.1, RFC 2068 1998: Dave Winer utvikler og publiserer XML-RPC 1999: HTTP/1.1 RFC 2616 2015: HTTP/2
  10. The co-author of foundational specifications such as HTTP/1.1 (RFC 2616) and URI (RFC 2396) 2000: Roy Fielding doctorate dissertation Architectural Styles and the Design of Network-based Software Architectures Chapter 5: Representational State Transfer REST
  11. What is REST, exactly? Difficult to answer. What I do know is that it is surrounded with a lot of misconceptions. I wish I had time to go through them all, but I’ve picked a couple of the most common ones here.
  12. The first misconception I’ve chosen is that REST maps directly to CRUD. It doesn’t. Without going into the details about REST being an architectural style and not a protocol, let’s go through the methods. POST can create, manipulate or represent any method. It is used to tunnel the whole SOAP protocol, for instance. PUT can both create and replace, but not really update a resource. Only GET and DELETE map, the rest of the methods does something completely different. Secondly, focusing on CRUD will lead to a badly designed API.
  13. The second misconception is about URIs. URIs, then. Are they important? Which of these are most RESTful? RESTful URI: You have no idea. That doesn’t mean pretty and human readable, consistent URIs aren’t important. But from a REST perspective, it is just an opaque identifier. You will discover URIs through hypermedia, so what it is shouldn’t matter one ounce. What's important is what surrounds the URI, such as the: method input data response
  14. Does this look familiar? Who thinks this is good API documentation? If your API is overly concerned with URIs and enumerating them in the documentation, you don't have a RESTful API. You have what Stefan Tilkov calls a “URI API” The bad thing about this is that you burden the clients with server details, while giving up control over something the server should be master of.
  15. Let's say you have a database table Wouldn't it be annoying if you couldn't rename it because a client you didn't control had the table name hard coded in its SQL statements?
  16. The right spelling of Referer is with two r's, but since you've made the clients dependent on your spelling error, you can never rename the table.
  17. You have what Stefan Tilkov calls a “URI API” The bad thing about this is that you burden the clients with server details, while giving up control over something the server should be master of.
  18. It's the same way with URI-dependent APIs. If you want to move a resource to a different URL, every client needs to be updated.
  19. If you want to make a backward incompatible change to the notes resource, you give it a new version number.
  20. You now need to give all resources a new version, even though they didn’t change. Do tedious work on your URIs and what operations you can perform on them Don’t write it down in documentation. Write it down into your resources instead, as inline hypermedia controls. Makes the resources self descriptive, decouples the client from the server and makes the server much more flexible in what it can do. URI templates are for APIs what GET <form> is for HTML.
  21. Roy Fielding gave a talk for the Adobe Evolve conference in 2013 There, he proposed the following question: What is the best practice for versioning a REST API? His answer?
  22. https://www.infoq.com/articles/roy-fielding-on-versioning/
  23. So, now that we know what REST is not, let’s discuss what it might be.
  24. I like to think of learning REST like learning a foreign language. A study called: "The Foreign-Language Effect: Thinking in a Foreign Tongue Reduces Decision Biases” (by Boaz Keysar, Sayuri L. Hayakawa and Sun Gyu An in Psychological Science) http://www.economist.com/blogs/johnson/2012/05/foreign-languages-and-thinking Proves that different languages affect how we think, act and feel.
  25. The same applies to architectural principles and programming languages. Who here knows functional programming? Would you say it makes you think and develop differently than you do (or did) with procedural languages? It at least means that you can't use your RPC competency and just apply it to REST. You will fail.
  26. REST consists of 6 constraints. Another way to look at it: Guarantees.
  27. Of all the constraints, I believe the last one here is both most important and less understood. That's why I'm going to try to explain it.
  28. In an 2014 interview with Mike Amundsen, Roy Fielding said this. https://www.infoq.com/articles/roy-fielding-on-versioning/
  29. Links and operations
  30. Those links and operations are analogous to real-life affordances, as popularized by Don Norman in his book the "Design of Everyday things”. Like a cup “wants” to be held and lifted and a button “wants” to be pushed, hypermedia should explain to the client what the resource ”wants” the client to do.
  31. Don Norman defines an affordance by “Do people know what to do based on what they see?”
  32. In the same way, we can define hypermedia by “do machines know what to do based on what they see”.
  33. So, how does hypermedia look like? Does it look familiar? Forms are hypermedia recipes of how the next request is going to look like How do we transport our knowledge of hypermedia in HTML to an API?
  34. Let's start by reformatting the HTML
  35. Replacing all attributes with common ones, makes it more consistent and more "API-like".
  36. Making further adjustments
  37. Like generating a new WSDL in the response to every request. Just like HTML.
  38. So, how can we use hypermedia in practice? As REST defines, hypermedia should be the engine of application state. Here’s what that means.
  39. Let's use a toaster as an example
  40. Initial state of a toaster is Off. We turn it on, and it reaches on status, eventually heating our bread. After it has been heating for a while, it reaches an upper temperature limit Bringing it into an idle state. When it reaches a lower temperature limit, it will go back into heating state. Eventually, the bread will be done and the toaster will enter the shutting down state Ending in the off state, just as we started.
  41. If we turn our toaster into an HTTP resource, how does it look like? Let's try to GET it.
  42. We can see that it has an off state
  43. We can also see that it has an operation that allows us to turn it on
  44. Let's look at that operation a little more closely
  45. If we just reformat it a little
  46. It starts looking like an HTTP request
  47. Well, look at that! The toaster is now on. We see that we can now turn it off again, but we can also increase the heating strength. By the way, does anyone notice anything different hre
  48. Well, look at that! The toaster is now on. We see that we can now turn it off again, but we can also increase the heating strength. By the way, does anyone notice anything different hre
  49. Well, look at that! The toaster is now on. We see that we can now turn it off again, but we can also increase the heating strength. By the way, does anyone notice anything different here?
  50. Ah. The toaster is now heating at strength 3. We see that we can still turn it off and adjust the strength. But what about that ID up there? Doesn't that look suspiciously like a URI?
  51. It seems the toaster has reached an upper temperature limit, putting it into an idle state. Although it may look like it, we did not alter the state of the toaster with our GET request. We just discovered that the state had changed, by doing a safe, idempotent request.
  52. Let's repeat the GET request and see what's happened. Seems like our bread is done and the toaster is shutting down. We now have no available operations, since we can't do anything while the toaster is shutting down.
  53. Getting back to versioning, when you use hypermedia, you're much more flexible: Adding properties to JSON is fine. Adding relations to new resources is fine. Adding new representations to the same resource is also fine. So we have a lot of ways we can guide new clients to new content without: Affecting old clients Adding a version number to our URIs
  54. You can reach me on: Twitter E-mail Slack. Join the HTTP API slack! It's full of great people in love with the web and APIs.