HTTP Methods
How They Relate to RESTful API's
About Me
Herman J. Radtke III

Web Architect at HauteLook
  Design the RESTful API

Writing PHP for 9 years

Maintain pecl/gearman and pecl/memcache
Perspective
HauteLook's API is for internal use
  Very few restrictions on design
  Example: Netflix

Many companies have an external API
  Concerned with how the design affects
  other clients (ex: flash)
  Examples: Twilio, Jira, Facebook
Why?
REST is an architectural style




Not satisfied with the existing explanations
GET vs POST




Do we actually know the differences?
GET vs POST
I ask every interviewee this question.

Common answers:
GET does not send a body in the request

POST can send more data

POST is more secure
Idempotence
Idempotence means no side-effects.

This is the most important difference!
  GET is idempotent (safe)
  POST is not idempotent (unsafe)

It allows the web to scale.
Improper use of GET
<a href=”/logout.php”>Logout</a>

We just broke the internet
  Caching proxies
  Browser "accelerator" plugins

Better to use a form with the POST method

Other example: Tracking Pixels
POST vs PUT
POST is create and PUT is update, right?

Not so simple
  Methods do not map to CRUD
  CRUD can map to the methods

Key difference?
  PUT is idempotent!
Create Using POST
Create Using PUT
Update Using POST 1/2
Update Using POST 2/2
Update Using PUT
Other HTTP Methods
PATCH

DELETE

HEAD

OPTIONS
Additional Resources
RFC 2616 Method Definitions - http://www.
w3.org/Protocols/rfc2616/rfc2616-sec9.html

#rest on freenode

My twitter - @hermanradtke

RESTful APIs with Herman Radtke