Slide 1

Slide 1 text

Your HTTP API is not RESTful @jakobmattsson www.jakobm.com

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Current status

Slide 6

Slide 6 text

RESTful API GET PUT POST DELETE Resource URLs

Slide 7

Slide 7 text

Your HTTP API is not RESTful @jakobmattsson www.jakobm.com

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

”I am getting frustrated by the number of people calling any HTTP-based interface a REST API.” ! ”That is RPC.” - me

Slide 10

Slide 10 text

- Roy Fielding ”I am getting frustrated by the number of people calling any HTTP-based interface a REST API.” ! ”That is RPC.”

Slide 11

Slide 11 text

REST? Representational state transfer is an abstraction of the architecture of the World Wide Web. WWW is an ”instance” of REST.

Slide 12

Slide 12 text

What is… the Internet?

Slide 13

Slide 13 text

What is… the Internet?

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Welcome to the Internet I will be your guide

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

The world wide web is HTML over HTTP

Slide 18

Slide 18 text

The world wide web is HTML over HTTP HyperText Markup Language over HyperText Transfer Protocol

Slide 19

Slide 19 text

”Hypertext is text with references (hyperlinks) to other text which the reader can immediately access, or where text can be revealed progressively at multiple levels of detail.”

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Hypertext does not need to be HTML on a browser. ! Machines can follow links when they understand the data format and relationship types.

Slide 23

Slide 23 text

So… REST over HTTP?

Slide 24

Slide 24 text

An Internet media type for the data (JSON, XML, HTML, images, video etc). ! Standard HTTP methods (GET, PUT, POST, or DELETE), with the corresponding semantics. ! Hypertext links to reference state. ! Hypertext links to reference related resources.

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

HyperLinks leads to… ! HATEOAS

Slide 27

Slide 27 text

Hypermedia as the Engine of Application State

Slide 28

Slide 28 text

A constraint of the REST application architecture that distinguishes it from most other network application architectures Hypermedia as the Engine of Application State

Slide 29

Slide 29 text

A client interacts with a network application entirely through hypermedia provided dynamically by application servers. ! A client needs no prior knowledge about how to interact with any particular application or server beyond a generic understanding of hypermedia.

Slide 30

Slide 30 text

By contrast, in a service-oriented architecture (SOA), clients and servers interact through a fixed interface shared through documentation or an interface description language (IDL).

Slide 31

Slide 31 text

link: "/projects/99"

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

When your API feels like using the web itself… ! THEN you’re starting to become RESTful.

Slide 34

Slide 34 text

• No fixed resource names • No fixed hierarchies • Servers own the namespace • Servers instruct clients (links, forms etc) 1. No fixation

Slide 35

Slide 35 text

• No types of significance for the client • Use media types • Use standardized relation names 2. No types

Slide 36

Slide 36 text

• One entry point • State driven by client selections • Server provides options 3. No prior knowledge

Slide 37

Slide 37 text

The HATEOAS constraint decouples client and server in a way that allows the server functionality to evolve independently.

Slide 38

Slide 38 text

Changes in who can access what. ! Or what state transitions are valid. ! ! ! ! ! ! ! ! ! All mistakes related to WHAT url you can request WHEN, they go away.

Slide 39

Slide 39 text

What does this look like in JSON? ! Let’s actually browse the API. ! Start from a native format, with various templates for other media types.

Slide 40

Slide 40 text

DEMO

Slide 41

Slide 41 text

Most people make the mistake that it should be simple to design simple things. ! In reality, the effort required to design something is inversely proportional to the simplicity of the result.

Slide 42

Slide 42 text

Frameworks ! Rails? ASP.NET MVC? Django? Play? Spring? Express?

Slide 43

Slide 43 text

Usually very RPC-like. ! Hope to see some alternatives in the future.

Slide 44

Slide 44 text

Your HTTP API is not RESTful @jakobmattsson www.jakobm.com