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

REST in Peace #DevoxxPL 2016 talk

REST in Peace #DevoxxPL 2016 talk

REST APIs are the language of the web. Though simple to build, it's also very easy to mess them up. You end up with a convoluted API, that's hard to understand and even worse to use. I want to show you how to create REST APIs that are both comprehensible are maintainable and make your fellow developers happy.

https://www.youtube.com/watch?v=c0nQEwfKlsM

Clemens Prerovsky

June 23, 2016
Tweet

More Decks by Clemens Prerovsky

Other Decks in Technology

Transcript

  1. POST both work for create & update & PUT {

    “firstname”: “clemens” } { “id”: “da796a”, “firstname”: “clemens”, “lastname”: “prerovsky”, … } partial data complete data
  2. GET / { “id”: 42 “_hidden”: true { <? {

    “.”: “!” “.deprecated_id”
  3. GET /ndoes HTTP/1.1 404 Not Found { “message”: “Not Found”,

    “description”: “We could not find an API endpoint named ‘ndoes’.” } provide body & description
  4. GET /api/v1/… $.getJSON( '/api/v1/nodes', success ); Accept: $.ajax({ url: '/nodes,

    headers: { Accept: 'application/json; version=1.0' } }).done(success); vs.
  5. auto- gen generic grade of automation none roll your ow

    n coding effort GUARANTEE BEST VALUE
  6. Resources Best Practices for Designing a Pragmatic RESTful API http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api

    REST API Design with Brian Sletten https://www.youtube.com/watch?v=HW9wWZHWhnI REST+JSON API Design - Best Practices for Developers https://www.youtube.com/watch?v=hdSrT4yjS1g Securing API Keys in a JavaScript Single Page App http://billpatrianakos.me/blog/2016/02/15/securing-api-keys-in-a- javascript-single-page-app/ REST Security Cheat Sheet https://www.owasp.org/index.php/REST_Security_Cheat_Sheet The art of innovation | Guy Kawasaki | TEDxBerkeley https://www.youtube.com/watch?v=Mtjatz9r-Vc The Fundamentals of REST API Design https://stormpath.com/blog/fundamentals-rest-api-design 10 Best Practices for Better RESTful API http://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better- restful-api/ REST WORST PRACTICES https://jacobian.org/writing/rest-worst-practices/ API Versioning http://symfony.com/doc/current/bundles/FOSRestBundle/versioning.html Architectural Styles and the Design of Network-based Software Architectures http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm Stop Comparing JSON and XML http://www.yegor256.com/2015/11/16/json-vs-xml.html Stop Writing REST API Clients http://ttezel.github.io/blog/2013/02/23/stop-writing-rest-api-clients/
  7. Images “The Triumph of Death” by Pieter Bruegel the Elder,

    1562 https://upload.wikimedia.org/wikipedia/commons/1/10/Thetriumphofdeath.jpg inspired by http://classicprogrammerpaintings.com/ Photo of Sad Puppy by Matthew Wiebe https://unsplash.com/photos/2Ts5HnA67k8 “Wildweibchen mit Einhorn”, Unknown Artist https://commons.wikimedia.org/wiki/File:Wildweibchen_mit_Einhorn.jpg “First World Problems MEME”, Unknown Artist https://imgflip.com/i/15t3ot Photo of Marie Curie, Unknown Artist https://commons.wikimedia.org/wiki/File:Marie_Curie_Tekniska_museet.jpg Hedgehog Belly Rub, Unknown Artist, via Reddit https://www.reddit.com/r/gifs/comments/3l3b6z/hedgehog_is_a_bit_too_happy_with_the_belly_rub/ “Botón Me gusta” by Enoc vt https://en.wikipedia.org/wiki/Facebook_like_button#/media/File:Bot%C3%B3n_Me_gusta.svg “Chuck Norris PSD” by xzeroherox http://www.officialpsds.com/Chuck-Norris-PSD41327.html “Fry Not Sure MEME”, Unknown Artist http://www.socialmemegenerator.com/meme-generator/not-sure-if-fry/