SlideShare a Scribd company logo
1 of 36
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

Viewers also liked

REST: Padrões e Melhores Práticas
REST: Padrões e Melhores PráticasREST: Padrões e Melhores Práticas
REST: Padrões e Melhores PráticasAlessandro Oliveira
 
Boas práticas no desenvolvimento de uma RESTful API
Boas práticas no desenvolvimento de uma RESTful APIBoas práticas no desenvolvimento de uma RESTful API
Boas práticas no desenvolvimento de uma RESTful APIFernando Camargo
 
Descobrindo APIs REST
Descobrindo APIs RESTDescobrindo APIs REST
Descobrindo APIs RESTGuilherme
 
APIs REST - Introdução e alguns conceitos
APIs REST - Introdução e alguns conceitosAPIs REST - Introdução e alguns conceitos
APIs REST - Introdução e alguns conceitosFelix Costa
 
APIs Rest(Ful): como fazer, por Alex Piaz
APIs Rest(Ful): como fazer, por Alex PiazAPIs Rest(Ful): como fazer, por Alex Piaz
APIs Rest(Ful): como fazer, por Alex PiaziMasters
 
Segurança de APIs HTTP, um guia sensato para desenvolvedores preocupados
Segurança de APIs HTTP, um guia sensato para desenvolvedores preocupadosSegurança de APIs HTTP, um guia sensato para desenvolvedores preocupados
Segurança de APIs HTTP, um guia sensato para desenvolvedores preocupadosLuis Cipriani
 
OAuth2: Uma abordagem para segurança de aplicações e APIs REST - Devcamp 2014
OAuth2: Uma abordagem para segurança de aplicações e APIs REST  - Devcamp 2014OAuth2: Uma abordagem para segurança de aplicações e APIs REST  - Devcamp 2014
OAuth2: Uma abordagem para segurança de aplicações e APIs REST - Devcamp 2014Tiago Marchetti Dolphine
 
TDC 2015 - Segurança em Recursos RESTful com OAuth2
TDC 2015 - Segurança em Recursos RESTful com OAuth2TDC 2015 - Segurança em Recursos RESTful com OAuth2
TDC 2015 - Segurança em Recursos RESTful com OAuth2Rodrigo Cândido da Silva
 

Viewers also liked (8)

REST: Padrões e Melhores Práticas
REST: Padrões e Melhores PráticasREST: Padrões e Melhores Práticas
REST: Padrões e Melhores Práticas
 
Boas práticas no desenvolvimento de uma RESTful API
Boas práticas no desenvolvimento de uma RESTful APIBoas práticas no desenvolvimento de uma RESTful API
Boas práticas no desenvolvimento de uma RESTful API
 
Descobrindo APIs REST
Descobrindo APIs RESTDescobrindo APIs REST
Descobrindo APIs REST
 
APIs REST - Introdução e alguns conceitos
APIs REST - Introdução e alguns conceitosAPIs REST - Introdução e alguns conceitos
APIs REST - Introdução e alguns conceitos
 
APIs Rest(Ful): como fazer, por Alex Piaz
APIs Rest(Ful): como fazer, por Alex PiazAPIs Rest(Ful): como fazer, por Alex Piaz
APIs Rest(Ful): como fazer, por Alex Piaz
 
Segurança de APIs HTTP, um guia sensato para desenvolvedores preocupados
Segurança de APIs HTTP, um guia sensato para desenvolvedores preocupadosSegurança de APIs HTTP, um guia sensato para desenvolvedores preocupados
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
OAuth2: Uma abordagem para segurança de aplicações e APIs REST  - Devcamp 2014OAuth2: Uma abordagem para segurança de aplicações e APIs REST  - Devcamp 2014
OAuth2: Uma abordagem para segurança de aplicações e APIs REST - Devcamp 2014
 
TDC 2015 - Segurança em Recursos RESTful com OAuth2
TDC 2015 - Segurança em Recursos RESTful com OAuth2TDC 2015 - Segurança em Recursos RESTful com OAuth2
TDC 2015 - Segurança em Recursos RESTful com OAuth2
 

Similar to REST API Dos and Dont's: Best Practices for Designing RESTful APIs

From REST to Hypermedia APIs with Spring by Vladimir Tsukur
From REST to Hypermedia APIs with Spring by Vladimir TsukurFrom REST to Hypermedia APIs with Spring by Vladimir Tsukur
From REST to Hypermedia APIs with Spring by Vladimir TsukurJavaDayUA
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringGlobalLogic Ukraine
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringVladimir Tsukur
 
How APIs Can Be Secured in Mobile Environments
How APIs Can Be Secured in Mobile EnvironmentsHow APIs Can Be Secured in Mobile Environments
How APIs Can Be Secured in Mobile EnvironmentsWSO2
 
Api development with rails
Api development with railsApi development with rails
Api development with railsEdwin Cruz
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial IntroPamela Fox
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Mario Cardinal
 
API-Entwicklung bei XING
API-Entwicklung bei XINGAPI-Entwicklung bei XING
API-Entwicklung bei XINGMark Schmidt
 
Confessions of-a-gadget-holic
Confessions of-a-gadget-holicConfessions of-a-gadget-holic
Confessions of-a-gadget-holicTyrell Perera
 
Bootstrapping an App for Launch
Bootstrapping an App for LaunchBootstrapping an App for Launch
Bootstrapping an App for LaunchCraig Phares
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsTom Johnson
 
RefCard RESTful API Design
RefCard RESTful API DesignRefCard RESTful API Design
RefCard RESTful API DesignOCTO Technology
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Tech Community
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Tech Community
 
2011 august-gdd-mexico-city-rest-json-oauth
2011 august-gdd-mexico-city-rest-json-oauth2011 august-gdd-mexico-city-rest-json-oauth
2011 august-gdd-mexico-city-rest-json-oauthikailan
 
How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxChanna Ly
 

Similar to REST API Dos and Dont's: Best Practices for Designing RESTful APIs (20)

From REST to Hypermedia APIs with Spring by Vladimir Tsukur
From REST to Hypermedia APIs with Spring by Vladimir TsukurFrom REST to Hypermedia APIs with Spring by Vladimir Tsukur
From REST to Hypermedia APIs with Spring by Vladimir Tsukur
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with Spring
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with Spring
 
How APIs Can Be Secured in Mobile Environments
How APIs Can Be Secured in Mobile EnvironmentsHow APIs Can Be Secured in Mobile Environments
How APIs Can Be Secured in Mobile Environments
 
Api development with rails
Api development with railsApi development with rails
Api development with rails
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
 
AIR & API
AIR & APIAIR & API
AIR & API
 
Getting Started with API Management
Getting Started with API ManagementGetting Started with API Management
Getting Started with API Management
 
API-Entwicklung bei XING
API-Entwicklung bei XINGAPI-Entwicklung bei XING
API-Entwicklung bei XING
 
Confessions of-a-gadget-holic
Confessions of-a-gadget-holicConfessions of-a-gadget-holic
Confessions of-a-gadget-holic
 
Bootstrapping an App for Launch
Bootstrapping an App for LaunchBootstrapping an App for Launch
Bootstrapping an App for Launch
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
RefCard RESTful API Design
RefCard RESTful API DesignRefCard RESTful API Design
RefCard RESTful API Design
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
 
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needsMicrosoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
 
2011 august-gdd-mexico-city-rest-json-oauth
2011 august-gdd-mexico-city-rest-json-oauth2011 august-gdd-mexico-city-rest-json-oauth
2011 august-gdd-mexico-city-rest-json-oauth
 
How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptx
 
Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 

Recently uploaded

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

REST API Dos and Dont's: Best Practices for Designing RESTful APIs

  • 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