SlideShare a Scribd company logo
1 of 28
Join the discussion at
https://bit.ly/phpbucharest
#phpbucharest
Bucharest PHP
Meetup #10
Powered by
Agenda
18:45 - 19:00 Meet & Greet
19:00 - 20:00 A RESTful
Introduction
20:00 - 21:00 Networking
Ask questions using sli.do app
Event code: #phpmeetup
A RESTful Introduction
About us
XP:
● Programming & CS
○ 15 years
● Web & eCommerce
○ 10 years
● APIs & Services
○ 7+ years
● Large scale Enterprise
Software Architecture
○ 3+ years
Product Owner
@ eMAG
Andrei Pîrjoleanu
XP:
● Programming
○ 12+ years
● Trainer
○ 5 years
● eCommerce
○ 5 years
● APIs & Services
○ 9 years
Software Engineer
@ eMAG
Daniel Toader
3
/dantdr /danieltoader@dantdr/andreipirjoleanu /neneaX
Agenda
The RESTful road
What is REST? Principles Real World
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
4
Questions via sli.do
5
#phpmeetup
What is REST?
6
What, when, who, how
REpresentational State TransferRESTRESTfulRESTish
7
Who?
Roy Fielding defined REST in his 2000
PhD dissertation "Architectural Styles
and the Design of Network-based
Software Architectures" at UC Irvine.
Definition
What?
Representational state transfer (REST)
is a software architectural style that
defines a set of constraints to be used for
creating Web services.
When?
The REST architectural style has been
developed in parallel with HTTP 1.1 of
1996–1999, based on the existing
design of HTTP 1.0 of 1996.
8
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
Architectural Properties
Non-functional requirements
The constraints of the REST architectural style affect the following architectural properties:
● performance in component interactions, which can be the dominant factor in user-perceived performance and network
efficiency;
● scalability allowing the support of large numbers of components and interactions among components;
● simplicity of a uniform interface;
● modifiability of components to meet changing needs (even while the application is running);
● visibility of communication between components by service agents;
● portability of components by moving program code with the data;
● reliability in the resistance to failure at the system level in the presence of failures within components, connectors, or data.
9
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
Constraints
Web’s Architectural style
10
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
Client - Server1
Servers and clients may also be replaced and
developed independently, as long as the interface
between them is not altered.
Stateless2
No client context shall be stored on the server
between requests. The client is responsible for
managing the state of the application.
Cacheable3
Well-managed caching partially or completely
eliminates some client-server interactions, further
improving scalability and performance.
#phpmeetup
Constraints
Web’s Architectural style
11
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
Uniform Interfaces4
The uniform interface simplifies and decouples the
architecture, which enables each part to evolve
independently.
Layered System5
The client should only know the immediate layer it is
communicating with, and not be aware of any layers
behind it.
Code on demand6
A server can extend the functionality of a client on
runtime, by sending code to it that it should execute
(like PHP, Java Applets, or JavaScript).optional
#phpmeetup
RESTful principles
Helping applications to be simple, lightweight, and fast
12
Resources
What is a resource?
REST uses a resource identifier to identify the particular resource involved in an interaction between components.
The state of resource at any particular timestamp is known as resource representation.
The key abstraction of information
in REST is a resource.
”Roy Fielding’s dissertation
“
A resource can be anything that can be named:
● A document
● An image
● A temporal service
● A collection of other resources
● A non-virtual object (e.g.: a person)
13
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
Methods
What is a resource method?
A large number of people wrongly relate resource methods to HTTP GET/PUT/POST/DELETE methods.
The Uniform interface constraint should be applied and thus consistency should be followed, regardless of the chosen
implementation.
The clients and servers exchange representations of resources by using a standardized interface and protocol – typically HTTP.
Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML,
XML, plain text, PDF, JPEG, JSON, and others.
REST and HTTP are not the same.A resource method is used to perform the transition to
the next desired state of the resource representation.
14
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
HTTP design
Modeling & Best practices
Consistency is the key
● Archetypes can be used with consistent naming convention
1. Document (singular concept) - singular name
2. Collection (server managed) - plural name
3. Store (client-managed) - plural name
4. Controller - verb
➔ http://api.local/ad/
➔ http://api.local/management/
➔ http://api.local/ad/teams/{code}
➔ http://api.local/ad/users/{id}
➔ http://api.local/ad/teams/{code}/users/{id}
➔ http://api.local/ad/teams/{code}/users/{id}/resync
15
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
HTTP design
Modeling & Best practices
Consistency is the key
● HTTP Request methods can be used to manipulate resources
1. GET - Retrieve resource
2. POST - Create resource
3. PUT - Replace resource
4. PATCH - Apply delta (diff) between states (similar to SQL migrations)
5. DELETE - Remove resource
Uniform interface - HTTP POST can be used for updating a resource instead of HTTP PUT as long as it is consistent – it’s alright
and application interface will be RESTful.
Nevertheless, most well-designed APIs will use the verbs consistently and the same as any other API.
16
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
HTTP design
Modeling & Best practices
Consistency is the key
● HTTP Request methods can be used to manipulate resources
● Retrieve all
● Filter through all
● Retrieve single
● Add single
● Replace single
● Replace all
● Remove single
● Remove all
➔ GET http://api.local/ad/users
➔ GET http://api.local/ad/users?name=john
➔ GET http://api.local/ad/users/{id}
➔ POST http://api.local/ad/users
➔ PUT http://api.local/ad/users/{id}
➔ PUT http://api.local/ad/users
➔ DELETE http://api.local/ad/users/{id}
➔ DELETE http://api.local/ad/users
17
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
HTTP design
Modeling & Best practices
Consistency is the key
● HTTP Status codes can be used to inform clients
● 200 - OK
● 404 - Not Found
● 403 - Forbidden
● 201 - Created
● 202 - Accepted
● 405 - Method Not Allowed
● 500 - Internal Server Error
● 501 - Not Implemented
➔ GET http://api.local/ad/users
➔ GET http://api.local/ad/users?name=john
➔ GET http://api.local/ad/users/{id}
➔ POST http://api.local/ad/users
➔ PUT http://api.local/ad/users/{id}
➔ PUT http://api.local/ad/users
➔ DELETE http://api.local/ad/users/{id}
➔ DELETE http://api.local/ad/users
18
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
HTTP design
Modeling & Best practices
Consistency is the key
● HTTP Headers and Payloads
● Accept: application/json; - return JSON response
● Content-Type: application/json; - send JSON request
● Content-Type: application/xml; - send XML request
● Accept-version: v1 - use version v1 according to custom header
● Accept: application/vnd.example.v1 - use version v1 according to vendor specific media type header
● Authorization: Basic Zm9vOmJhcg== - use basic authorization header
● X-App-Auth: 123456abcdefgh - use token authorization with custom header
19
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
Maturity Levels
Leonard Richardson Maturity Model
Single URI & single verb
SOAP
Multiple URI-based resources & single verbs
Resources
Multiple URI-based resources and verbs
HTTP Verbs
Level 0 Level 1 Level 2 Level 3
Self-explanatory response
HATEOAS
20
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
Maturity Levels
Hypermedia as the Engine of Application State
HATEOAS is an architectural style that lets you use
hypermedia links in the response contents so that the client
can dynamically navigate.
References example - JSON REST API hypermedia links:
○ RFC 5988 (web linking)
■ Target URI
■ Link relation type
■ Attributes for target IRI
○ JSON Hypermedia API Language (HAL)
{
"data": [
{
"code": "j9x3p32gfv",
"name": "Edited List",
"created_at": "2019-09-23T22:51:57+00:00",
"updated_at": "2019-09-24T02:28:47+00:00"
}
],
"errors": [],
"page": {
"size": 1,
"total": 4,
"number": 3
},
"links": {
"self": "/todolist?page=3",
"first": "/todolist?page=1",
"last": "/todolist?page=4",
"next": "/todolist?page=4",
"prev": "/todolist?page=2"
}
}
21
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
Real world
Entering the matrix
22
ToDo List
Demo
Simple, RESTful API
example
23
APX
Application Programming eXperience
To deliver great APIs, design must be a first-order concern.
Optimizing for APX (API User Experience) should be a primary
concern in API development, as UX (User Experience) has
become a primary concern in UI development.
An optimal API design enables applications developers to easily
understand the purpose and functionality of the API so that they
can quickly become productive using it.
APX is to API as
UX is to UI
”
“
24
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
Tools
Resources
● Swagger - https://swagger.io/
● PHPStorm - https://www.jetbrains.com/help/phpstorm/testing-restful-web-services.html
● Postman - https://www.getpostman.com/
● RAML - https://raml.org/
● RESTful API - https://restfulapi.net/
25
W
hatisREST?
Principles
RealW
orld
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
Recap
The RESTful road
26
What is REST? Principles Real World
Definition
Properties
Constraints
Resources
Methods
HTTPdesign
APX
Tools
MaturityLevels
Demo
Q&A
#phpmeetup
27
Q&A
27
#phpmeetup
Thank you!
28
Continue the discussion at
http://bit.ly/phpbucharest
#phpbucharest

More Related Content

What's hot

HTML5 & Friends
HTML5 & FriendsHTML5 & Friends
HTML5 & FriendsRemy Sharp
 
Crash Course HTML/Rails Slides
Crash Course HTML/Rails SlidesCrash Course HTML/Rails Slides
Crash Course HTML/Rails SlidesUdita Plaha
 
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScriptHTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScriptTodd Anglin
 
HTML5 and Search Engine Optimization (SEO)
HTML5 and Search Engine Optimization (SEO)HTML5 and Search Engine Optimization (SEO)
HTML5 and Search Engine Optimization (SEO)Performics.Convonix
 
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
Navigating the critical rendering path -  Jamie Alberico - VirtuaConNavigating the critical rendering path -  Jamie Alberico - VirtuaCon
Navigating the critical rendering path - Jamie Alberico - VirtuaConJamie Indigo
 
The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014Tommie Gannert
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008Association Paris-Web
 
Fundamentals of Web for Non-Developers
Fundamentals of Web for Non-DevelopersFundamentals of Web for Non-Developers
Fundamentals of Web for Non-DevelopersLemi Orhan Ergin
 
Java script Tutorial - QaTrainingHub
Java script Tutorial - QaTrainingHubJava script Tutorial - QaTrainingHub
Java script Tutorial - QaTrainingHubQA TrainingHub
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical WritingSarah Maddox
 
HTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayHTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayTodd Anglin
 
webservices overview
webservices overviewwebservices overview
webservices overviewelliando dias
 
Rendering strategies: Measuring the devil's details in core web vitals - Jam...
Rendering strategies:  Measuring the devil's details in core web vitals - Jam...Rendering strategies:  Measuring the devil's details in core web vitals - Jam...
Rendering strategies: Measuring the devil's details in core web vitals - Jam...Jamie Indigo
 
DPC2007 Zend Framework (Gaylord Aulke)
DPC2007 Zend Framework (Gaylord Aulke)DPC2007 Zend Framework (Gaylord Aulke)
DPC2007 Zend Framework (Gaylord Aulke)dpc
 
XML and Web Services with Groovy
XML and Web Services with GroovyXML and Web Services with Groovy
XML and Web Services with GroovyPaul King
 
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)dpc
 
Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015Edward Burns
 

What's hot (20)

HTML5 & Friends
HTML5 & FriendsHTML5 & Friends
HTML5 & Friends
 
Crash Course HTML/Rails Slides
Crash Course HTML/Rails SlidesCrash Course HTML/Rails Slides
Crash Course HTML/Rails Slides
 
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScriptHTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
 
HTML5 and Search Engine Optimization (SEO)
HTML5 and Search Engine Optimization (SEO)HTML5 and Search Engine Optimization (SEO)
HTML5 and Search Engine Optimization (SEO)
 
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
Navigating the critical rendering path -  Jamie Alberico - VirtuaConNavigating the critical rendering path -  Jamie Alberico - VirtuaCon
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
 
Improving qa on php projects
Improving qa on php projectsImproving qa on php projects
Improving qa on php projects
 
The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
 
Fundamentals of Web for Non-Developers
Fundamentals of Web for Non-DevelopersFundamentals of Web for Non-Developers
Fundamentals of Web for Non-Developers
 
Java script Tutorial - QaTrainingHub
Java script Tutorial - QaTrainingHubJava script Tutorial - QaTrainingHub
Java script Tutorial - QaTrainingHub
 
RESTful design
RESTful designRESTful design
RESTful design
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical Writing
 
HTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayHTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use Today
 
webservices overview
webservices overviewwebservices overview
webservices overview
 
Rendering strategies: Measuring the devil's details in core web vitals - Jam...
Rendering strategies:  Measuring the devil's details in core web vitals - Jam...Rendering strategies:  Measuring the devil's details in core web vitals - Jam...
Rendering strategies: Measuring the devil's details in core web vitals - Jam...
 
DPC2007 Zend Framework (Gaylord Aulke)
DPC2007 Zend Framework (Gaylord Aulke)DPC2007 Zend Framework (Gaylord Aulke)
DPC2007 Zend Framework (Gaylord Aulke)
 
XML and Web Services with Groovy
XML and Web Services with GroovyXML and Web Services with Groovy
XML and Web Services with Groovy
 
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
 
Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015
 

Similar to A RESTful introduction

RESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel MardjanRESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel MardjanJexia
 
Innovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open InterfacesInnovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open InterfacesSteve Speicher
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20Phil Wilkins
 
ReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... YawnReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... Yawnozten
 
GlueCon 2018: Are REST APIs Still Relevant Today?
GlueCon 2018: Are REST APIs Still Relevant Today?GlueCon 2018: Are REST APIs Still Relevant Today?
GlueCon 2018: Are REST APIs Still Relevant Today?LaunchAny
 
Designing RESTful APIs
Designing RESTful APIsDesigning RESTful APIs
Designing RESTful APIsanandology
 
Simple Web Services with PHP
Simple Web Services with PHPSimple Web Services with PHP
Simple Web Services with PHPJohn Paul Ada
 
Rapid Web Development with Python for Absolute Beginners
Rapid Web Development with Python for Absolute BeginnersRapid Web Development with Python for Absolute Beginners
Rapid Web Development with Python for Absolute BeginnersFatih Karatana
 
API (Application program interface)
API (Application program interface)API (Application program interface)
API (Application program interface)Muhammad Jahanzaib
 
Unify service and ui layer automation bdd way.pptx (1)
Unify service and ui layer automation bdd way.pptx (1)Unify service and ui layer automation bdd way.pptx (1)
Unify service and ui layer automation bdd way.pptx (1)Shivaling Sannalli
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using PhpSudheer Satyanarayana
 

Similar to A RESTful introduction (20)

Cqrs api v2
Cqrs api v2Cqrs api v2
Cqrs api v2
 
RESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel MardjanRESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel Mardjan
 
Cqrs api
Cqrs apiCqrs api
Cqrs api
 
PPT - A slice of cake php
PPT - A slice of cake phpPPT - A slice of cake php
PPT - A slice of cake php
 
HTTP Basics Demo
HTTP Basics DemoHTTP Basics Demo
HTTP Basics Demo
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
Innovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open InterfacesInnovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open Interfaces
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
ReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... YawnReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... Yawn
 
GlueCon 2018: Are REST APIs Still Relevant Today?
GlueCon 2018: Are REST APIs Still Relevant Today?GlueCon 2018: Are REST APIs Still Relevant Today?
GlueCon 2018: Are REST APIs Still Relevant Today?
 
Designing RESTful APIs
Designing RESTful APIsDesigning RESTful APIs
Designing RESTful APIs
 
API
APIAPI
API
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289
 
Simple Web Services with PHP
Simple Web Services with PHPSimple Web Services with PHP
Simple Web Services with PHP
 
Rapid Web Development with Python for Absolute Beginners
Rapid Web Development with Python for Absolute BeginnersRapid Web Development with Python for Absolute Beginners
Rapid Web Development with Python for Absolute Beginners
 
API (Application program interface)
API (Application program interface)API (Application program interface)
API (Application program interface)
 
Unify service and ui layer automation bdd way.pptx (1)
Unify service and ui layer automation bdd way.pptx (1)Unify service and ui layer automation bdd way.pptx (1)
Unify service and ui layer automation bdd way.pptx (1)
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using Php
 

Recently uploaded

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 

Recently uploaded (20)

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 

A RESTful introduction

  • 1. Join the discussion at https://bit.ly/phpbucharest #phpbucharest Bucharest PHP Meetup #10 Powered by Agenda 18:45 - 19:00 Meet & Greet 19:00 - 20:00 A RESTful Introduction 20:00 - 21:00 Networking Ask questions using sli.do app Event code: #phpmeetup
  • 3. About us XP: ● Programming & CS ○ 15 years ● Web & eCommerce ○ 10 years ● APIs & Services ○ 7+ years ● Large scale Enterprise Software Architecture ○ 3+ years Product Owner @ eMAG Andrei Pîrjoleanu XP: ● Programming ○ 12+ years ● Trainer ○ 5 years ● eCommerce ○ 5 years ● APIs & Services ○ 9 years Software Engineer @ eMAG Daniel Toader 3 /dantdr /danieltoader@dantdr/andreipirjoleanu /neneaX
  • 4. Agenda The RESTful road What is REST? Principles Real World Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A 4
  • 6. What is REST? 6 What, when, who, how
  • 8. Who? Roy Fielding defined REST in his 2000 PhD dissertation "Architectural Styles and the Design of Network-based Software Architectures" at UC Irvine. Definition What? Representational state transfer (REST) is a software architectural style that defines a set of constraints to be used for creating Web services. When? The REST architectural style has been developed in parallel with HTTP 1.1 of 1996–1999, based on the existing design of HTTP 1.0 of 1996. 8 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 9. Architectural Properties Non-functional requirements The constraints of the REST architectural style affect the following architectural properties: ● performance in component interactions, which can be the dominant factor in user-perceived performance and network efficiency; ● scalability allowing the support of large numbers of components and interactions among components; ● simplicity of a uniform interface; ● modifiability of components to meet changing needs (even while the application is running); ● visibility of communication between components by service agents; ● portability of components by moving program code with the data; ● reliability in the resistance to failure at the system level in the presence of failures within components, connectors, or data. 9 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 10. Constraints Web’s Architectural style 10 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A Client - Server1 Servers and clients may also be replaced and developed independently, as long as the interface between them is not altered. Stateless2 No client context shall be stored on the server between requests. The client is responsible for managing the state of the application. Cacheable3 Well-managed caching partially or completely eliminates some client-server interactions, further improving scalability and performance. #phpmeetup
  • 11. Constraints Web’s Architectural style 11 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A Uniform Interfaces4 The uniform interface simplifies and decouples the architecture, which enables each part to evolve independently. Layered System5 The client should only know the immediate layer it is communicating with, and not be aware of any layers behind it. Code on demand6 A server can extend the functionality of a client on runtime, by sending code to it that it should execute (like PHP, Java Applets, or JavaScript).optional #phpmeetup
  • 12. RESTful principles Helping applications to be simple, lightweight, and fast 12
  • 13. Resources What is a resource? REST uses a resource identifier to identify the particular resource involved in an interaction between components. The state of resource at any particular timestamp is known as resource representation. The key abstraction of information in REST is a resource. ”Roy Fielding’s dissertation “ A resource can be anything that can be named: ● A document ● An image ● A temporal service ● A collection of other resources ● A non-virtual object (e.g.: a person) 13 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 14. Methods What is a resource method? A large number of people wrongly relate resource methods to HTTP GET/PUT/POST/DELETE methods. The Uniform interface constraint should be applied and thus consistency should be followed, regardless of the chosen implementation. The clients and servers exchange representations of resources by using a standardized interface and protocol – typically HTTP. Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML, XML, plain text, PDF, JPEG, JSON, and others. REST and HTTP are not the same.A resource method is used to perform the transition to the next desired state of the resource representation. 14 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 15. HTTP design Modeling & Best practices Consistency is the key ● Archetypes can be used with consistent naming convention 1. Document (singular concept) - singular name 2. Collection (server managed) - plural name 3. Store (client-managed) - plural name 4. Controller - verb ➔ http://api.local/ad/ ➔ http://api.local/management/ ➔ http://api.local/ad/teams/{code} ➔ http://api.local/ad/users/{id} ➔ http://api.local/ad/teams/{code}/users/{id} ➔ http://api.local/ad/teams/{code}/users/{id}/resync 15 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 16. HTTP design Modeling & Best practices Consistency is the key ● HTTP Request methods can be used to manipulate resources 1. GET - Retrieve resource 2. POST - Create resource 3. PUT - Replace resource 4. PATCH - Apply delta (diff) between states (similar to SQL migrations) 5. DELETE - Remove resource Uniform interface - HTTP POST can be used for updating a resource instead of HTTP PUT as long as it is consistent – it’s alright and application interface will be RESTful. Nevertheless, most well-designed APIs will use the verbs consistently and the same as any other API. 16 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 17. HTTP design Modeling & Best practices Consistency is the key ● HTTP Request methods can be used to manipulate resources ● Retrieve all ● Filter through all ● Retrieve single ● Add single ● Replace single ● Replace all ● Remove single ● Remove all ➔ GET http://api.local/ad/users ➔ GET http://api.local/ad/users?name=john ➔ GET http://api.local/ad/users/{id} ➔ POST http://api.local/ad/users ➔ PUT http://api.local/ad/users/{id} ➔ PUT http://api.local/ad/users ➔ DELETE http://api.local/ad/users/{id} ➔ DELETE http://api.local/ad/users 17 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 18. HTTP design Modeling & Best practices Consistency is the key ● HTTP Status codes can be used to inform clients ● 200 - OK ● 404 - Not Found ● 403 - Forbidden ● 201 - Created ● 202 - Accepted ● 405 - Method Not Allowed ● 500 - Internal Server Error ● 501 - Not Implemented ➔ GET http://api.local/ad/users ➔ GET http://api.local/ad/users?name=john ➔ GET http://api.local/ad/users/{id} ➔ POST http://api.local/ad/users ➔ PUT http://api.local/ad/users/{id} ➔ PUT http://api.local/ad/users ➔ DELETE http://api.local/ad/users/{id} ➔ DELETE http://api.local/ad/users 18 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 19. HTTP design Modeling & Best practices Consistency is the key ● HTTP Headers and Payloads ● Accept: application/json; - return JSON response ● Content-Type: application/json; - send JSON request ● Content-Type: application/xml; - send XML request ● Accept-version: v1 - use version v1 according to custom header ● Accept: application/vnd.example.v1 - use version v1 according to vendor specific media type header ● Authorization: Basic Zm9vOmJhcg== - use basic authorization header ● X-App-Auth: 123456abcdefgh - use token authorization with custom header 19 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 20. Maturity Levels Leonard Richardson Maturity Model Single URI & single verb SOAP Multiple URI-based resources & single verbs Resources Multiple URI-based resources and verbs HTTP Verbs Level 0 Level 1 Level 2 Level 3 Self-explanatory response HATEOAS 20 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 21. Maturity Levels Hypermedia as the Engine of Application State HATEOAS is an architectural style that lets you use hypermedia links in the response contents so that the client can dynamically navigate. References example - JSON REST API hypermedia links: ○ RFC 5988 (web linking) ■ Target URI ■ Link relation type ■ Attributes for target IRI ○ JSON Hypermedia API Language (HAL) { "data": [ { "code": "j9x3p32gfv", "name": "Edited List", "created_at": "2019-09-23T22:51:57+00:00", "updated_at": "2019-09-24T02:28:47+00:00" } ], "errors": [], "page": { "size": 1, "total": 4, "number": 3 }, "links": { "self": "/todolist?page=3", "first": "/todolist?page=1", "last": "/todolist?page=4", "next": "/todolist?page=4", "prev": "/todolist?page=2" } } 21 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 24. APX Application Programming eXperience To deliver great APIs, design must be a first-order concern. Optimizing for APX (API User Experience) should be a primary concern in API development, as UX (User Experience) has become a primary concern in UI development. An optimal API design enables applications developers to easily understand the purpose and functionality of the API so that they can quickly become productive using it. APX is to API as UX is to UI ” “ 24 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 25. Tools Resources ● Swagger - https://swagger.io/ ● PHPStorm - https://www.jetbrains.com/help/phpstorm/testing-restful-web-services.html ● Postman - https://www.getpostman.com/ ● RAML - https://raml.org/ ● RESTful API - https://restfulapi.net/ 25 W hatisREST? Principles RealW orld Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 26. Recap The RESTful road 26 What is REST? Principles Real World Definition Properties Constraints Resources Methods HTTPdesign APX Tools MaturityLevels Demo Q&A #phpmeetup
  • 28. Thank you! 28 Continue the discussion at http://bit.ly/phpbucharest #phpbucharest