SlideShare a Scribd company logo
REST API
Dos and
Dont`s
@abonfiglio
Adriano Bonfiglio
What is REST and RESTful APIs
HTTP Methods
HTTP Status Code
Resources and Endpoints
Relations
Pagination
DEMO
Authentication
Agenda
SAP Labs Latin America
Adriano Bonfiglio
300,000
customers in
190 countries
More than
76,500
employees and offices in
130 countries
More than
€ 20,8
billion
in 2015
Annual revenue of
A 44-year history of innovation and
growth as a true industry leader
The best company to work
for in Brazil
Named by Você S/A magazine and
Great Place to Work
2015
2015
2015
Multi-cultural environment
Training (+24 hours/year/employee)
Competitive compensation policy
Flexible working time
Flexible benefits
SAP Bus
Free drinks & snacks
Benefits
Bachelor degree
in progress or complete
IT Technical knowledge
Business process knowledge
Advanced English skills
Spanish skills (plus)
Passion for innovation
Team player
How to work @ SAP
http://bit.ly/1Qs0Z7a
Join our talent community!
And get to know about our opportunities
REST
REpresentational
State
Transfer
RESTful
REST Webservice
REST API
REST API v1
router.get("/app/users/findAll", userController.list);
response: {message: ok, results:[...]}
router.get("/app/user/findOne/:id", userController.findOne);
response: {message: ok, results:{}}
router.post("/app/user/update/:id", userController.update);
response: {message: ok, results:{}}
router.post("/app/user/save", userController.save);
response: {message: ok, results:{}}
router.get("/app/user/delete/:id", userController.remove);
response: {message: ok}
router.get("/app/users/findAll", userController.list);
response: {message: ok, results:[...]}
router.get("/app/user/findOne/:id", userController.findOne);
response: {message: ok, results:{}}
router.post("/app/user/update/:id", userController.update);
response: {message: ok, results:{}}
router.post("/app/user/save", userController.save);
response: {message: ok, results:{}}
router.get("/app/user/delete/:id", userController.remove);
response: {message: ok}
FIRST PROBLEM
REST API v1
HTTP Methods
GET
POST
get a representation of a resource
create a new resource
PUT update a resource
PATCH update part of a resource
DELETE delete a resource
router.get("/app/users/findAll", userController.list);
response: {message: ok, results:[...]}
router.get("/app/user/findOne/:id", userController.findOne);
response: {message: ok, results:{}}
router.put("/app/user/update/:id", userController.update);
response: {message: ok, results:{}}
router.post("/app/user/save", userController.save);
response: {message: ok, results:{}}
router.delete("/app/user/delete/:id", userController.remove);
response: {message: ok}
REST API v2
router.get("/app/users/findAll", userController.list);
response: {message: ok, results:[...]}
router.get("/app/user/findOne/:id", userController.findOne);
response: {message: ok, results:{}}
router.put("/app/user/update/:id", userController.update);
response: {message: ok, results:{}}
router.post("/app/user/save", userController.save);
response: {message: ok, results:{}}
router.delete("/app/user/delete/:id", userController.remove);
response: {message: ok}
SECOND PROBLEM
REST API v2
HTTP Status
2xx Success
3xx Redirection
200: Ok
201: Created
204: No content
304: Not modified
4xx Client Error 404: Not Found,
400: Bad Request,
401: Unauthorized,
403: Forbidden,
405: Method not allowed,
422: Unprocessable Entity
router.get("/app/users/findAll", userController.list);
response: HTTP1.1 200 OK {message: “”, results:[...]}
router.get("/app/user/findOne/:id", userController.findOne);
response: HTTP1.1 200 OK {message: ok, results:{}}
router.put("/app/user/update/:id", userController.update);
response: HTTP1.1 200 OK {message: “”, results:{}}
router.post("/app/user/save", userController.save);
response: HTTP1.1 201 Created {message: “”, results:{}}
router.delete("/app/user/delete/:id", userController.remove);
response: HTTP1.1 204 No Content
REST API v3
router.get("/app/users/findAll", userController.list);
response: HTTP1.1 200 OK {message: “”, results:[...]}
router.get("/app/user/findOne/:id", userController.findOne);
response: HTTP1.1 200 OK {message: ok, results:{}}
router.put("/app/user/update/:id", userController.update);
response: HTTP1.1 200 OK {message: “”, results:{}}
router.post("/app/user/save", userController.save);
response: HTTP1.1 201 Created {message: “”, results:{}}
router.delete("/app/user/delete/:id", userController.remove);
response: HTTP1.1 204 No Content
REST API v3
router.get("/app/users/findAll", userController.list);
response: HTTP1.1 200 OK {message: “”, results:[...]}
router.get("/app/user/findOne/:id", userController.findOne);
response: HTTP1.1 200 OK {message: ok, results:{}}
router.put("/app/user/update/:id", userController.update);
response: HTTP1.1 200 OK {message: “”, results:{}}
router.post("/app/user/save", userController.save);
response: HTTP1.1 201 Created {message: “”, results:{}}
router.delete("/app/user/delete/:id", userController.remove);
response: HTTP1.1 204 No Content
REST API v3
THIRD PROBLEM
Resources and Enpoints
Nouns
Plural
Consistent
router.get("/app/users/", userController.list);
response: HTTP1.1 200 OK {message: “”, results:[...]}
router.get("/app/users/:id", userController.findOne);
response: HTTP1.1 200 OK {message:””, results:{}}
router.put("/app/users/:id", userController.update);
response: HTTP1.1 200 OK {message: “”, results:{}}
router.post("/app/users/", userController.save);
response: HTTP1.1 201 Created {message: “”, results:{}}
router.delete("/app/users/:id", userController.remove);
response: HTTP1.1 204 No Content
REST API v4
What about Relations?
User
Role
router.get("/app/users/:id/roles", userController.findAll);
response: HTTP1.1 200 OK {message:””, results:{}}
router.get("/app/users/:id/roles/:roleId", userController.findOne);
response: HTTP1.1 200 OK {message:””, results:{}}
router.put("/app/users/:id/roles/:roleId", userController.update);
response: HTTP1.1 200 OK {message: “”, results:{}}
router.post("/app/users/:id/roles", userController.save);
response: HTTP1.1 201 Created {message: “”, results:{}}
router.delete("/app/users/:id/roles/:id", userController.remove);
response: HTTP1.1 204 No Content
What about Relations?
GET /app/users?page=1&order=desc&sort=name
What about Pagination?
GET /app/users?fields=name,lastname
Fields
Keep it Simple
GET http://got/hodor
Respose:
HTTP1.1 200 OK
{
“message”:”hodor”
}
GET http://localhost://users/1
Respose:
HTTP1.1 200 OK
{
“c_id”:”1”,
“c_interna_id”:”12132”,
“c_Name”:”foo”,
“c_lastName”:”barr”,
“c_structure”: {
“reference”:”32434”,
“code”:”2454435”,
},
“c: last_modified”: “02-29-2016”
}
Keep it clear & clean
GET http://localhost://users/1
Respose:
HTTP1.1 200 OK
{
“id”:”1”,
“name”:”foo”,
“lastName”:”barr”,
“last_modified”: “02-29-2016”
}
Keep it clear & clean
DEMO
Authentication
GET / HTTP/1.1
Host: example.org
Authorization: Basic Zm9vOmJhcg=
BASIC
Authentication
GET / HTTP/1.1
Host: example.org
Authorization: Basic Zm9vOmJhcg=
BASIC
Authentication
DIGEST
Authentication
OAUTH2
References
RESTful Web APIs – O`REILLY
https://developer.github.com/v3/
https://developers.trello.com/advanced-reference
https://github.com/adrianobonfiglio/rest-api
THANKS!
Questions?

More Related Content

PPTX
Headless Drupal
PPTX
Native web architcture
PDF
What's new in Java EE 7? From HTML5 to JMS 2.0
PPT
GWT: Our Experiences
PDF
Lesson 09
PPT
Gwt Presentation1
PDF
Lesson 09
PDF
Integrating Node.js with PHP
Headless Drupal
Native web architcture
What's new in Java EE 7? From HTML5 to JMS 2.0
GWT: Our Experiences
Lesson 09
Gwt Presentation1
Lesson 09
Integrating Node.js with PHP

Viewers also liked (8)

PPTX
REST: Padrões e Melhores Práticas
ODP
Boas práticas no desenvolvimento de uma RESTful API
PDF
Descobrindo APIs REST
PDF
APIs REST - Introdução e alguns conceitos
PDF
APIs Rest(Ful): como fazer, por Alex Piaz
PDF
Segurança de APIs HTTP, um guia sensato para desenvolvedores preocupados
PPTX
OAuth2: Uma abordagem para segurança de aplicações e APIs REST - Devcamp 2014
PDF
TDC 2015 - Segurança em Recursos RESTful com OAuth2
REST: Padrões e Melhores Práticas
Boas práticas no desenvolvimento de uma RESTful API
Descobrindo APIs REST
APIs REST - Introdução e alguns conceitos
APIs Rest(Ful): como fazer, por Alex Piaz
Segurança de APIs HTTP, um guia sensato para desenvolvedores preocupados
OAuth2: Uma abordagem para segurança de aplicações e APIs REST - Devcamp 2014
TDC 2015 - Segurança em Recursos RESTful com OAuth2
Ad

Similar to Rest API's (20)

PDF
ITB2016 - Building ColdFusion RESTFul Services
PPTX
RESTful API - Best Practices
PPT
RESTful API In Node Js using Express
PPTX
Building-Robust-APIs-ASPNET-Web-API-and-RESTful-Patterns.pptx
PPTX
Pragmatic REST APIs
PPTX
"Best Practices for Designing a Pragmatic RESTful API
PPTX
PDF
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
PPTX
RESTful API Design Best Practices Using ASP.NET Web API
PDF
Don't screw it up! How to build durable API
PPTX
An Introduction To REST API
PPTX
Http and REST APIs.
PPTX
ASP.NET Web API
PPTX
RESTful APIs in .NET
PPTX
Rest API Design Rules
PDF
Recipes for API Ninjas
PDF
Rest ful tools for lazy experts
PDF
RESTFul Tools For Lazy Experts - CFSummit 2016
PDF
Consumer centric api design v0.4.0
ITB2016 - Building ColdFusion RESTFul Services
RESTful API - Best Practices
RESTful API In Node Js using Express
Building-Robust-APIs-ASPNET-Web-API-and-RESTful-Patterns.pptx
Pragmatic REST APIs
"Best Practices for Designing a Pragmatic RESTful API
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
RESTful API Design Best Practices Using ASP.NET Web API
Don't screw it up! How to build durable API
An Introduction To REST API
Http and REST APIs.
ASP.NET Web API
RESTful APIs in .NET
Rest API Design Rules
Recipes for API Ninjas
Rest ful tools for lazy experts
RESTFul Tools For Lazy Experts - CFSummit 2016
Consumer centric api design v0.4.0
Ad

Recently uploaded (20)

PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
TLE Review Electricity (Electricity).pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PPTX
1. Introduction to Computer Programming.pptx
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
Modernising the Digital Integration Hub
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPT
Module 1.ppt Iot fundamentals and Architecture
WOOl fibre morphology and structure.pdf for textiles
TLE Review Electricity (Electricity).pptx
1 - Historical Antecedents, Social Consideration.pdf
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
DP Operators-handbook-extract for the Mautical Institute
1. Introduction to Computer Programming.pptx
Getting started with AI Agents and Multi-Agent Systems
Developing a website for English-speaking practice to English as a foreign la...
Chapter 5: Probability Theory and Statistics
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
A comparative study of natural language inference in Swahili using monolingua...
Final SEM Unit 1 for mit wpu at pune .pptx
Hindi spoken digit analysis for native and non-native speakers
A novel scalable deep ensemble learning framework for big data classification...
Modernising the Digital Integration Hub
Univ-Connecticut-ChatGPT-Presentaion.pdf
O2C Customer Invoices to Receipt V15A.pptx
Tartificialntelligence_presentation.pptx
Module 1.ppt Iot fundamentals and Architecture

Rest API's

  • 2. What is REST and RESTful APIs HTTP Methods HTTP Status Code Resources and Endpoints Relations Pagination DEMO Authentication Agenda
  • 3. SAP Labs Latin America Adriano Bonfiglio
  • 4. 300,000 customers in 190 countries More than 76,500 employees and offices in 130 countries More than € 20,8 billion in 2015 Annual revenue of A 44-year history of innovation and growth as a true industry leader
  • 5. The best company to work for in Brazil Named by Você S/A magazine and Great Place to Work 2015 2015 2015
  • 6. Multi-cultural environment Training (+24 hours/year/employee) Competitive compensation policy Flexible working time Flexible benefits SAP Bus Free drinks & snacks Benefits
  • 7. Bachelor degree in progress or complete IT Technical knowledge Business process knowledge Advanced English skills Spanish skills (plus) Passion for innovation Team player How to work @ SAP
  • 8. http://bit.ly/1Qs0Z7a Join our talent community! And get to know about our opportunities
  • 12. REST API v1 router.get("/app/users/findAll", userController.list); response: {message: ok, results:[...]} router.get("/app/user/findOne/:id", userController.findOne); response: {message: ok, results:{}} router.post("/app/user/update/:id", userController.update); response: {message: ok, results:{}} router.post("/app/user/save", userController.save); response: {message: ok, results:{}} router.get("/app/user/delete/:id", userController.remove); response: {message: ok}
  • 13. router.get("/app/users/findAll", userController.list); response: {message: ok, results:[...]} router.get("/app/user/findOne/:id", userController.findOne); response: {message: ok, results:{}} router.post("/app/user/update/:id", userController.update); response: {message: ok, results:{}} router.post("/app/user/save", userController.save); response: {message: ok, results:{}} router.get("/app/user/delete/:id", userController.remove); response: {message: ok} FIRST PROBLEM REST API v1
  • 14. HTTP Methods GET POST get a representation of a resource create a new resource PUT update a resource PATCH update part of a resource DELETE delete a resource
  • 15. router.get("/app/users/findAll", userController.list); response: {message: ok, results:[...]} router.get("/app/user/findOne/:id", userController.findOne); response: {message: ok, results:{}} router.put("/app/user/update/:id", userController.update); response: {message: ok, results:{}} router.post("/app/user/save", userController.save); response: {message: ok, results:{}} router.delete("/app/user/delete/:id", userController.remove); response: {message: ok} REST API v2
  • 16. router.get("/app/users/findAll", userController.list); response: {message: ok, results:[...]} router.get("/app/user/findOne/:id", userController.findOne); response: {message: ok, results:{}} router.put("/app/user/update/:id", userController.update); response: {message: ok, results:{}} router.post("/app/user/save", userController.save); response: {message: ok, results:{}} router.delete("/app/user/delete/:id", userController.remove); response: {message: ok} SECOND PROBLEM REST API v2
  • 17. HTTP Status 2xx Success 3xx Redirection 200: Ok 201: Created 204: No content 304: Not modified 4xx Client Error 404: Not Found, 400: Bad Request, 401: Unauthorized, 403: Forbidden, 405: Method not allowed, 422: Unprocessable Entity
  • 18. router.get("/app/users/findAll", userController.list); response: HTTP1.1 200 OK {message: “”, results:[...]} router.get("/app/user/findOne/:id", userController.findOne); response: HTTP1.1 200 OK {message: ok, results:{}} router.put("/app/user/update/:id", userController.update); response: HTTP1.1 200 OK {message: “”, results:{}} router.post("/app/user/save", userController.save); response: HTTP1.1 201 Created {message: “”, results:{}} router.delete("/app/user/delete/:id", userController.remove); response: HTTP1.1 204 No Content REST API v3
  • 19. router.get("/app/users/findAll", userController.list); response: HTTP1.1 200 OK {message: “”, results:[...]} router.get("/app/user/findOne/:id", userController.findOne); response: HTTP1.1 200 OK {message: ok, results:{}} router.put("/app/user/update/:id", userController.update); response: HTTP1.1 200 OK {message: “”, results:{}} router.post("/app/user/save", userController.save); response: HTTP1.1 201 Created {message: “”, results:{}} router.delete("/app/user/delete/:id", userController.remove); response: HTTP1.1 204 No Content REST API v3
  • 20. router.get("/app/users/findAll", userController.list); response: HTTP1.1 200 OK {message: “”, results:[...]} router.get("/app/user/findOne/:id", userController.findOne); response: HTTP1.1 200 OK {message: ok, results:{}} router.put("/app/user/update/:id", userController.update); response: HTTP1.1 200 OK {message: “”, results:{}} router.post("/app/user/save", userController.save); response: HTTP1.1 201 Created {message: “”, results:{}} router.delete("/app/user/delete/:id", userController.remove); response: HTTP1.1 204 No Content REST API v3 THIRD PROBLEM
  • 22. router.get("/app/users/", userController.list); response: HTTP1.1 200 OK {message: “”, results:[...]} router.get("/app/users/:id", userController.findOne); response: HTTP1.1 200 OK {message:””, results:{}} router.put("/app/users/:id", userController.update); response: HTTP1.1 200 OK {message: “”, results:{}} router.post("/app/users/", userController.save); response: HTTP1.1 201 Created {message: “”, results:{}} router.delete("/app/users/:id", userController.remove); response: HTTP1.1 204 No Content REST API v4
  • 24. router.get("/app/users/:id/roles", userController.findAll); response: HTTP1.1 200 OK {message:””, results:{}} router.get("/app/users/:id/roles/:roleId", userController.findOne); response: HTTP1.1 200 OK {message:””, results:{}} router.put("/app/users/:id/roles/:roleId", userController.update); response: HTTP1.1 200 OK {message: “”, results:{}} router.post("/app/users/:id/roles", userController.save); response: HTTP1.1 201 Created {message: “”, results:{}} router.delete("/app/users/:id/roles/:id", userController.remove); response: HTTP1.1 204 No Content What about Relations?
  • 27. Keep it Simple GET http://got/hodor Respose: HTTP1.1 200 OK { “message”:”hodor” }
  • 28. GET http://localhost://users/1 Respose: HTTP1.1 200 OK { “c_id”:”1”, “c_interna_id”:”12132”, “c_Name”:”foo”, “c_lastName”:”barr”, “c_structure”: { “reference”:”32434”, “code”:”2454435”, }, “c: last_modified”: “02-29-2016” } Keep it clear & clean
  • 29. GET http://localhost://users/1 Respose: HTTP1.1 200 OK { “id”:”1”, “name”:”foo”, “lastName”:”barr”, “last_modified”: “02-29-2016” } Keep it clear & clean
  • 30. DEMO
  • 31. Authentication GET / HTTP/1.1 Host: example.org Authorization: Basic Zm9vOmJhcg= BASIC
  • 32. Authentication GET / HTTP/1.1 Host: example.org Authorization: Basic Zm9vOmJhcg= BASIC
  • 35. References RESTful Web APIs – O`REILLY https://developer.github.com/v3/ https://developers.trello.com/advanced-reference https://github.com/adrianobonfiglio/rest-api