20160908 #NoAPIVersioning

10

Click here to load reader

Transcript of 20160908 #NoAPIVersioning

Page 1: 20160908 #NoAPIVersioning

#NoAPIVersioningMobile Tea #11 Stephen Vance

September 8, 2016

Page 2: 20160908 #NoAPIVersioning

Easy API Changes

Add an endpoint

Add an optional element or parameter

Remove something no one uses

👍

2

Page 3: 20160908 #NoAPIVersioning

Breaking API Changes

Removing something people use

Change a data type

Add a required parameter or element

Change the response structure

😖

3

Page 4: 20160908 #NoAPIVersioning

What Shouldn’t You Do?Don’t change! Let it break!

Version your endpoint namespace example.com/api/v2345/users

Version your API domain v456.example.com/api/users

Version your content type Content-type: application/vnd.example.user-v17+json

Version your content { version: 6543, … }

4

Page 5: 20160908 #NoAPIVersioning

What Should You Do?• Code for Compatibility

• Useful in short term

• Increasing complexity and cost over time

• Hypermedia (HAL, JSON-LD, Collection+JSON, …)

• Livin’ the dream

• Conceptual complexity

• Limited practical support

• Migration

• Managed compatibility with an expiration

5

Page 6: 20160908 #NoAPIVersioning

Code for Compatibility

Rename ⇒ Two options with sync or translation

Mandatory parameter ⇒ Optional parameter with default value

Deletion ⇒ Ignored optional

Type change ⇒ Type flexibility

6

Page 7: 20160908 #NoAPIVersioning

Hypermedia• Hypermedia Controls tell you what to do next for each

workflow option

• You still need to program the semantics of the options if they’re not strictly user injected

• Hypermedia Forms tell you the data content for each request

• You still need to program the semantics if it’s more complex than CRUD

• Hypermedia Templates tell you how to assemble the data into the request

7

Page 8: 20160908 #NoAPIVersioning

Migrations• Automatically generate compatibility changes and

rollback

• Manage application and lifecycle of compatibility

• Integrates with deployment systems to eliminate downtime

• Also applies to database schema

• Requires ability to sunset compatibility

• Coming to an environment near you. Watch this space!

8

Page 9: 20160908 #NoAPIVersioning

Resources

• Sebastian Lambla, “Versions are Evil: How to Do Without In Your API”

• Richardson & Amundsen, “RESTful Web APIs,” O’Reilly, 2013.

9

Page 10: 20160908 #NoAPIVersioning

Contact Me

Stephen Vance

http://www.vance.com

[email protected]

@StephenRVance

srvance on GitHub and LinkedIn

10