The perfect REST
Solution
Gabriele Mittica - @gabrielemittica
What is REST?
APICONF 2017- Gabriele Mittica
APICONF 2017- Gabriele Mittica
REST
Uniform
Interface
Stateless
Cacheable
Client
Server
Layered
Code on
Demand
REST HTTP
APICONF 2017- Gabriele Mittica
A REQUEST is a set of
Header and Body with a
specific VERB (action)
against an URI (resource)
Header
Body
Verb
on Uri
REQUEST
HTTP VERB
▪ POST: creation
▪ PUT: update
▪ GET: retrieve
▪ DELETE: cancellation
▪ POST+PUT+GET+DELETE = CRUD
▪ PATCH (optional): partial update
APICONF 2017- Gabriele Mittica
A RESPONSE is a set of
headers and body that returns a
specific status code to the client
Header
Body
Status
RESPONSE
APICONF 2017- Gabriele Mittica
APICONF 2017- Gabriele Mittica
Create the perfect url
▪ POST http://www.example.com/customers
▪ GET http://www.example.com/customers/33245
▪ POST http://www.example.com/customers/33245/orders
APICONF 2017 – Gabriele Mittica
Don’t be an artist!
Don’t do that:
▪ GET
http://api.example.com/services?op=update_customer&i
d=12345&format=json
▪ PUT http://api.example.com/customers/12345/update
APICONF 2017 – Gabriele Mittica
Use headers and body in the right way
RIGHT
[
{…},
{…},
{…},
{…}
]
//pagination in header
WRONG
{
‘’pagination’’: { ‘’from’’: 0, ‘’to’’: 10},
‘’data’’: [
{…},
{…},
{…}
]
}
APICONF 2017- Gabriele Mittica
In few words
▪ Work on resources
▪ Use headers, body and query params in the right way
▪ Find the best auth method for your needs
▪ Design layered APIs
APICONF 2017- Gabriele Mittica
Be simply REST
Thanks for Listening

Apiconf - The perfect REST solution

  • 1.
    The perfect REST Solution GabrieleMittica - @gabrielemittica
  • 2.
    What is REST? APICONF2017- Gabriele Mittica
  • 3.
    APICONF 2017- GabrieleMittica REST Uniform Interface Stateless Cacheable Client Server Layered Code on Demand
  • 4.
    REST HTTP APICONF 2017-Gabriele Mittica
  • 5.
    A REQUEST isa set of Header and Body with a specific VERB (action) against an URI (resource) Header Body Verb on Uri REQUEST
  • 6.
    HTTP VERB ▪ POST:creation ▪ PUT: update ▪ GET: retrieve ▪ DELETE: cancellation ▪ POST+PUT+GET+DELETE = CRUD ▪ PATCH (optional): partial update APICONF 2017- Gabriele Mittica
  • 7.
    A RESPONSE isa set of headers and body that returns a specific status code to the client Header Body Status RESPONSE
  • 8.
  • 9.
  • 10.
    Create the perfecturl ▪ POST http://www.example.com/customers ▪ GET http://www.example.com/customers/33245 ▪ POST http://www.example.com/customers/33245/orders APICONF 2017 – Gabriele Mittica
  • 11.
    Don’t be anartist! Don’t do that: ▪ GET http://api.example.com/services?op=update_customer&i d=12345&format=json ▪ PUT http://api.example.com/customers/12345/update APICONF 2017 – Gabriele Mittica
  • 12.
    Use headers andbody in the right way RIGHT [ {…}, {…}, {…}, {…} ] //pagination in header WRONG { ‘’pagination’’: { ‘’from’’: 0, ‘’to’’: 10}, ‘’data’’: [ {…}, {…}, {…} ] } APICONF 2017- Gabriele Mittica
  • 13.
    In few words ▪Work on resources ▪ Use headers, body and query params in the right way ▪ Find the best auth method for your needs ▪ Design layered APIs APICONF 2017- Gabriele Mittica
  • 14.
    Be simply REST Thanksfor Listening