SlideShare a Scribd company logo
Best Practices for RESTful Web
Services
Joël Franusic, Developer Evangelist, Twilio
Joël Franusic
Developer Evangelist, Twilio
@jf
https://github.com/jpf
Richardson Maturity Model
Speaking the same language …
“Strictly RESTful”
REST is not a standard
What REST is not …
• Pretty URLs
• XML over HTTP
• JSON over HTTP
The Constraints
• Client-Server
• Stateless
• Cacheable
• Uniform Interfaces
• Layered System
• Code on Demand (optional)
Let’s get started
Level 0: POX
The Constraints
• Client-Server
• Stateless
• Cacheable
• Layered System
• Uniform Interfaces
• Code on Demand (optional)
Uniform Interfaces
Four principles:
1.Identification of Resources
2.Manipulation of Resources through these Representations
3.Self-descriptive Messages
4.Hypermedia as the engine of application state (HATEOAS)
Resources == Nouns
Identification of Resources
Generally:
•/noun/id
•/noun/action/id
Collections too …
Generally
•/nouns
(notice the above is plural now)
Level 1: Resources
Uniform Interfaces
Four principles:
1.Identification of Resources
2.Manipulation of Resources through these Representations
3.Self-descriptive Messages
4.Hypermedia as the engine of application state (HATEOAS)
Manipulation through those
Interfaces
Within Twilio:
/2010-04-01/Accounts/{AccountSid}/Calls/{CAxxx}
/2010-04-01/Accounts/{AccountSid}/Conferences/{CFxxx}
/2010-04-01/Accounts/{AccountSid}/Notifications/{NOxxx}
/2010-04-01/Accounts/{AccountSid}/Recordings/{RExxx}
/2010-04-01/Accounts/{AccountSid}/Queues/{QUxxx}
/2010-04-01/Accounts/{AccountSid}/SMS/{SMxxx}
/2010-04-01/Accounts/{AccountSid}/Transcripts/{TRxxx}
GET
POST
PUT
DELETE

{none}
{only for Calls & SMS}
n/a
{only for Recordings}

OPTIONS, HEAD, PATCH, TRACE, CONNECT
Level 2: HTTP Verbs
Uniform Interfaces
Four principles:
1.Identification of Resources
2.Manipulation of Resources through these Representations
3.Self-descriptive Messages
4.Hypermedia as the engine of application state (HATEOAS)
Self Descriptive
Each message should tell you:
•How to process itself
•If that resource is cacheable
•How to request the next resource
Level 3: Hypermedia Controls
Uniform Interfaces
Four principles:
1.Identification of Resources
2.Manipulation of Resources through these Representations
3.Self-descriptive Messages
4.Hypermedia as the engine of application state (HATEOAS)
HATEOAS
“Clients make state transitions only through actions that are
dynamically identified within hypermedia by the server (e.g., by
hyperlinks“Clients make state transitions only through actions that
are dynamically identified within hypermedia by the server (e.g.,
by hyperlinks within hypertext). Except for simple fixed entry
points to the application, a client does not assume that any
particular action is available for any particular resources beyond
those described in representations previously received from the
server.”

Source: http://en.wikipedia.org/wiki/Representational_state_transfer#Guiding_principles_of_the_interface (Accessed 2013-11-01)
Choose Your Own Adventure
For example:
$ curl https://api.twilio.com/2010-04-01
<?xml version="1.0"?>
<TwilioResponse>
<Version>
<Name>2010-04-01</Name>
<Uri>/2010-04-01</Uri>
<SubresourceUris>
<Accounts>/2010-04-01/Accounts</Accounts>
</SubresourceUris>
</Version>
</TwilioResponse>
Another example:
<TwilioResponse>
<Account>
<Sid>ACxxxx</Sid>
<FriendlyName>Do you like my friendly name?</FriendlyName>
<Type>Full</Type>
<Status>active</Status>
<DateCreated>Wed, 02 Jan 2013 21:37:41 +0000</DateCreated>
<DateUpdated>Fri, 04 Jan 2013 01:15:02 +0000</DateUpdated>
<AuthToken>redacted</AuthToken>
<Uri>/2010-04-01/Accounts/ACxxxx</Uri>
<SubresourceUris>
<AvailablePhoneNumbers>/2010-04-01/Accounts/ACxxxx/AvailablePhoneNumbers</AvailablePhoneNumbers>
<Calls>/2010-04-01/Accounts/ACxxxx/Calls</Calls>
<Conferences>/2010-04-01/Accounts/ACxxxx/Conferences</Conferences>
<IncomingPhoneNumbers>/2010-04-01/Accounts/ACxxxx/IncomingPhoneNumbers</IncomingPhoneNumbers>
<Notifications>/2010-04-01/Accounts/ACxxxx/Notifications</Notifications>
<OutgoingCallerIds>/2010-04-01/Accounts/ACxxxx/OutgoingCallerIds</OutgoingCallerIds>
<Queues>/2010-04-01/Accounts/ACxxxx/Queues</Queues>
<Recordings>/2010-04-01/Accounts/ACxxxx/Recordings</Recordings>
<Sandbox>/2010-04-01/Accounts/ACxxxx/Sandbox</Sandbox>
<SMSMessages>/2010-04-01/Accounts/ACxxxx/SMS/Messages</SMSMessages>
<Transcriptions>/2010-04-01/Accounts/ACxxxx/Transcriptions</Transcriptions>
</SubresourceUris>
</Account>
</TwilioResponse>
Another example:
<TwilioResponse>
<Account>
<Sid>ACxxxx</Sid>
<FriendlyName>Do you like my friendly name?</FriendlyName>
<Type>Full</Type>
<Status>active</Status>
<DateCreated>Wed, 02 Jan 2013 21:37:41 +0000</DateCreated>
<DateUpdated>Fri, 04 Jan 2013 01:15:02 +0000</DateUpdated>
<AuthToken>redacted</AuthToken>
<Uri>/2010-04-01/Accounts/ACxxxx</Uri>
<SubresourceUris>
<AvailablePhoneNumbers>/2010-04-01/Accounts/ACxxxx/AvailablePhoneNumbers</AvailablePhoneNumbers>

<Calls>/2010-04-01/Accounts/ACxxxx/Calls</Calls>
<Conferences>/2010-04-01/Accounts/ACxxxx/Conferences</Conferences>
<IncomingPhoneNumbers>/2010-04-01/Accounts/ACxxxx/IncomingPhoneNumbers</IncomingPhoneNumbers>
<Notifications>/2010-04-01/Accounts/ACxxxx/Notifications</Notifications>
<OutgoingCallerIds>/2010-04-01/Accounts/ACxxxx/OutgoingCallerIds</OutgoingCallerIds>
<Queues>/2010-04-01/Accounts/ACxxxx/Queues</Queues>
<Recordings>/2010-04-01/Accounts/ACxxxx/Recordings</Recordings>
<Sandbox>/2010-04-01/Accounts/ACxxxx/Sandbox</Sandbox>
<SMSMessages>/2010-04-01/Accounts/ACxxxx/SMS/Messages</SMSMessages>
<Transcriptions>/2010-04-01/Accounts/ACxxxx/Transcriptions</Transcriptions>
</SubresourceUris>
</Account>
</TwilioResponse>
Another example:
<TwilioResponse>
<Account>
<Sid>ACxxxx</Sid>
<FriendlyName>Do you like my friendly name?</FriendlyName>
<Type>Full</Type>
<Status>active</Status>
<DateCreated>Wed, 02 Jan 2013 21:37:41 +0000</DateCreated>
<DateUpdated>Fri, 04 Jan 2013 01:15:02 +0000</DateUpdated>
<AuthToken>redacted</AuthToken>
<Uri>/2010-04-01/Accounts/ACxxxx</Uri>
<SubresourceUris>
<AvailablePhoneNumbers>/2010-04-01/Accounts/ACxxxx/AvailablePhoneNumbers</AvailablePhoneNumbers>
<Calls>/2010-04-01/Accounts/ACxxxx/Calls</Calls>
<Conferences>/2010-04-01/Accounts/ACxxxx/Conferences</Conferences>
<IncomingPhoneNumbers>/2010-04-01/Accounts/ACxxxx/IncomingPhoneNumbers</IncomingPhoneNumbers>
<Notifications>/2010-04-01/Accounts/ACxxxx/Notifications</Notifications>
<OutgoingCallerIds>/2010-04-01/Accounts/ACxxxx/OutgoingCallerIds</OutgoingCallerIds>
<Queues>/2010-04-01/Accounts/ACxxxx/Queues</Queues>
<Recordings>/2010-04-01/Accounts/ACxxxx/Recordings</Recordings>
<Sandbox>/2010-04-01/Accounts/ACxxxx/Sandbox</Sandbox>

<SMSMessages>/2010-04-01/Accounts/ACxxxx/SMS/Messages</SMSMessages>
<Transcriptions>/2010-04-01/Accounts/ACxxxx/Transcriptions</Transcriptions>
</SubresourceUris>
</Account>
</TwilioResponse>
Glory of REST.. eh?
Best Practices for RESTful Web Services
Joël Franusic
Developer Evangelist
@jf
Best Practices for RESTful Web Services
Additional Resources
•

http://en.wikipedia.org/wiki/http://en.wikipedia.org/wiki/HATEOAS

•

http://blog.steveklabnik.com/2011/07/03/nobody-understandsrest-or-http://blog.steveklabnik.com/2011/07/03/nobodyunderstands-rest-or-http.html

•

http://shop.oreilly.com/product/9780596529260.http://shop.
oreilly.com/product/9780596529260.do

•

http://http://videos.restfest.org

More Related Content

PPTX
Tosca explained
PPTX
Coding standards
PPTX
Introduction to Spring Framework
PDF
Best Practices in Web Service Design
PPTX
Api testing
PPT
Asynchronous Programming in C# - Part 1
PDF
What is REST API? REST API Concepts and Examples | Edureka
PPTX
Object oriented testing
Tosca explained
Coding standards
Introduction to Spring Framework
Best Practices in Web Service Design
Api testing
Asynchronous Programming in C# - Part 1
What is REST API? REST API Concepts and Examples | Edureka
Object oriented testing

What's hot (20)

PPTX
Ajax
PPTX
Requirement Analysis
PDF
DVGA writeup
PPTX
Dom(document object model)
PPTX
Non Functional Requirement.
PPTX
PHP FUNCTIONS
PDF
Spring Framework - Core
PPT
Automating security test using Selenium and OWASP ZAP - Practical DevSecOps
PPT
UML Diagrams
PPT
Node.js Express Framework
PDF
Software Engineering : Requirement Analysis & Specification
PPTX
Rest assured
PDF
Rest api 테스트 수행가이드
PDF
Rest web services
PPT
javaScript.ppt
PPT
Pressman ch-11-component-level-design
PPTX
Javascript conditional statements
PPTX
Introduction to APIs (Application Programming Interface)
Ajax
Requirement Analysis
DVGA writeup
Dom(document object model)
Non Functional Requirement.
PHP FUNCTIONS
Spring Framework - Core
Automating security test using Selenium and OWASP ZAP - Practical DevSecOps
UML Diagrams
Node.js Express Framework
Software Engineering : Requirement Analysis & Specification
Rest assured
Rest api 테스트 수행가이드
Rest web services
javaScript.ppt
Pressman ch-11-component-level-design
Javascript conditional statements
Introduction to APIs (Application Programming Interface)
Ad

Similar to Best Practices for RESTful Web Services (20)

PPTX
REST Methodologies
PPTX
Rest Webservice
PPTX
Service approach for development Rest API in Symfony2
PPT
PPTX
RESTful Web Services @AnkaraPHP meetup
PPTX
RESTful Services
PPTX
Richarson maturity model (HATEOAS)
PDF
REST API Recommendations
PDF
REST Basics
PPTX
RESTful Web Services.pptxbnbjmgbjbvvhvhj
PDF
7 Principles of API Design - Waza
DOCX
PPTX
Restful webservice
PDF
Great webapis
PDF
Writing RESTful Web Services
PPTX
Building Adaptable APIs with NARWHL (API Days Paris)
PPTX
Time to REST: testing web services
PDF
What are restful web services?
PDF
PDF
INTERFACE by apidays 2023 - Refining Your API: The Last Mile of API Design, J...
REST Methodologies
Rest Webservice
Service approach for development Rest API in Symfony2
RESTful Web Services @AnkaraPHP meetup
RESTful Services
Richarson maturity model (HATEOAS)
REST API Recommendations
REST Basics
RESTful Web Services.pptxbnbjmgbjbvvhvhj
7 Principles of API Design - Waza
Restful webservice
Great webapis
Writing RESTful Web Services
Building Adaptable APIs with NARWHL (API Days Paris)
Time to REST: testing web services
What are restful web services?
INTERFACE by apidays 2023 - Refining Your API: The Last Mile of API Design, J...
Ad

More from Salesforce Developers (20)

PDF
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
PDF
Maximizing Salesforce Lightning Experience and Lightning Component Performance
PDF
Local development with Open Source Base Components
PPTX
TrailheaDX India : Developer Highlights
PDF
Why developers shouldn’t miss TrailheaDX India
PPTX
CodeLive: Build Lightning Web Components faster with Local Development
PPTX
CodeLive: Converting Aura Components to Lightning Web Components
PPTX
Enterprise-grade UI with open source Lightning Web Components
PPTX
TrailheaDX and Summer '19: Developer Highlights
PDF
Live coding with LWC
PDF
Lightning web components - Episode 4 : Security and Testing
PDF
LWC Episode 3- Component Communication and Aura Interoperability
PDF
Lightning web components episode 2- work with salesforce data
PDF
Lightning web components - Episode 1 - An Introduction
PDF
Migrating CPQ to Advanced Calculator and JSQCP
PDF
Scale with Large Data Volumes and Big Objects in Salesforce
PDF
Replicate Salesforce Data in Real Time with Change Data Capture
PDF
Modern Development with Salesforce DX
PDF
Get Into Lightning Flow Development
PDF
Integrate CMS Content Into Lightning Communities with CMS Connect
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Local development with Open Source Base Components
TrailheaDX India : Developer Highlights
Why developers shouldn’t miss TrailheaDX India
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Converting Aura Components to Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
TrailheaDX and Summer '19: Developer Highlights
Live coding with LWC
Lightning web components - Episode 4 : Security and Testing
LWC Episode 3- Component Communication and Aura Interoperability
Lightning web components episode 2- work with salesforce data
Lightning web components - Episode 1 - An Introduction
Migrating CPQ to Advanced Calculator and JSQCP
Scale with Large Data Volumes and Big Objects in Salesforce
Replicate Salesforce Data in Real Time with Change Data Capture
Modern Development with Salesforce DX
Get Into Lightning Flow Development
Integrate CMS Content Into Lightning Communities with CMS Connect

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Electronic commerce courselecture one. Pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Electronic commerce courselecture one. Pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
MYSQL Presentation for SQL database connectivity
Network Security Unit 5.pdf for BCA BBA.
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Understanding_Digital_Forensics_Presentation.pptx
Review of recent advances in non-invasive hemoglobin estimation
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx

Best Practices for RESTful Web Services