SlideShare a Scribd company logo
RESTful APIs...
What, Why and How...
Web Application Architecture {MVC}
Presentation Layer
Business Layer
Data Access Layer
(SQL or ORM)
DB
Takes care of Content Representation. (HTML5, CSS3).
Computational Logic on data using language libraries.
Access data from DB using RAW SQL queries or an ORM
Data Storage System (SQLite, MySQL, ORACLE).
Presentation Layer
Business Layer
Web and Mobile App - Sharing the same DB.
Data Access Layer
(SQL or ORM)
DB
Presentation Layer
Business Layer
Data Access Layer
(SQL or ORM)
Web App Mobile App
MySQL
Web - HTML5 & CSS3
Mobile - Native GUI Libraries
Some part may repeat and
some may be unique.
Will be the same.
What's Different?
DRY - Do not Repeat Yourself
Lets combine the common logic
into a single layer that both apps can
leverage.
Web Service(s) Layer..
Presentation Layer
Business Layer
DB
MySQL
Presentation Layer
Web App Mobile App
Business Layer
HTTP
Communication
(URLified)
Exposing data in the form of APIs.
Notes:
Data access logic and common business
logic is segregated into a new layer.
Job of this layer is to get the data from data
sources and expose it to applications.
To access data, applications make HTTP
request to a particular URL, and gets back
the required data as response.
WSL, can be thought of as an API driven
SQL Engine, which in addition to expose
data, allows applications to Create (Insert)
new data into the system.
Web Service(s) Layer
So, What are web services anyway?
Web services can be thought of as web application that is intended to
be used by Machines (Computers, Mobiles or any other device) as
opposed to humans.
Philosophically, they can be described as Webified SQL engine, that
allows client applications to make queries, insert new data, update or
delete existing data.
Design Approaches:
Traditional Way - SOAP based web services (SOAP, WSDL, UDDI, WS*)
Today's Way - REST based APIs.
Web application intended to be used by machines.
Application consuming data through APIs.
How does this all fall into work?
Web Service(s) Layer
DB
MySQL
HTTP Request
& Response
/v1/task
s
Json data
Presentation Logic
Data Management
& May be some
business logic.
HTTP
Various Applications
Single Data Access
& Management
layer.
Designing URL endpoints for our APIs
Requirement - Use Case Possible URL
To get all the tasks /v1/get-all-tasks
To get a particular task /v1/get-task/{id}
To create a task /v1/create-task
To delete a task /v1/delete-task/{id}
To update a task /v1/update-task/{id}
To get all tasks for a particular user /v1/get-tasks-for-users/{userId}
We may iterate over these APIs to see if we can improve...
Before understanding REST, lets design URI endpoints for an hypothetical
application to track tasks and their associated users.
SO, What's REST?
Representational State Transfer. (You don't need to remember :) )
In simple terms, server will return representation of state of the resource.
Representation may include data in XML, JSON or any other format.
REST is resource oriented architecture. Everything revolves around
resources.
What is resource?
Resource is any entity that you may want to expose and that can be named.
Typically, Each entity in ER-Diagram can be thought of as a resource.
In our application, we may have resources such as - Tasks and Users.
Don't worry, we shall see the practicals shortly.
REST guidelines (Principles)
2 URI's per resource.
1. Listing (collection) - /v1/tasks
2. Detail - /v1/tasks/{id}
Use nouns instead of verbs to name resources.So, instead of saying
/v1/getAllTasks, we should say /v1/tasks.
This means, we need to revise all our URIs to follow rest principles.
Prefer plurals over singular:/tasks over /task.
Huh..we might need to Redo our work... :(
Lets redesign our URI endpoints to follow REST principles.
For associations: /resource/{id}/resourceIn our case, we may have
/user/8908/tasks, to get all the tasks for a user.
So, we are making progress in the right way now..
RESTified APIs (URL endpoints)...
Requirement - Use Case Possible URLs REST based URLs
To get all the tasks /v1/get-all-tasks /v1/tasks
To get a particular task /v1/get-task/{id} /v1/tasks/{id}
To create a task /v1/create-task/{id} /v1/tasks/
To delete a task /v1/delete-task/{id} /v1/tasks/{id}
To update a task /v1/update-task /v1/tasks/{id}
To get all tasks for a
particular user
/v1/get-tasks-for-
users/{userId}
/v1/users/{id}/tasks
Lets iterate over our APIs to see if we can apply REST principles on it..
How will the server know when
to create, update or delete..
Lets find it out..
CRUD operations on REST APIs.
Telling server what action to perform..
HTTP provides request methods, that tells server what action to perform on
a URI.
HTTP provides methods that can be directly mapped to RDBMS CRUD
Operation. These methods include - GET, POST, PUT, DELETE.
Hmm..Lets see
how our APIs
should respond
to these
methods.
Resource
POST
(Create)
GET
(Read)
PUT
(Update)
DELETE
(Delete)
/tasks
Create a new
task
Return all
tasks
Replace all tasks
with new tasks.
Delete all
tasks
/tasks/123
Create a task
inside another
task.
Return a
specific task
Update this task if
exist or create a
new one.
Delete this
task.
Responding to various HTTP methods..
Needs to be handled with care. (We may not implement them)
Well, this seems great..but how do applications come to know if their request
succeeded or anything went wrong. (Specially for PUT and POST)?
Lets dig into HTTP to see if we can find an answer...
HTTP - Response Codes
Server sends response code for every client request. This communicates to
clients what happened to the their request (Pass, fail, error etc).
Response code for each type of request
Range (From
client
perspective)
Status code Method Comments.
1XX (100 - 199) * - Informational * Request is accepted and is in
progress
2xx (200 - 299) -
Success
200 - OK GET Request is served.
201 - Created POST /
PUT
Whenever a server create new
resource on client's request
202 - Accepted * Server accepted the requested but will
be processed later.
204 - No
Content
PUT Server performed the request but has
no data to return.
Range (From client
perspective)
Status code Method Comments.
3XX - Redirection 301 -
Permanently
moved
GET Server redirects client to the new URL of
the same resource.
4xx (400 - 499) -
Client Side
Problem
400 - Bad
Request.
* Client has used either wrong URL or
parameters, or provided insufficient data
in the request.
401 -
Unauthorized.
* Client is unauthorized to make this
request. (May be client have passed
wrong credentials)
404 - Not Found GET The request resource cannot be found.
5xx (500 - 599) -
Server Side
Problem
500 - internal
server error.
* Server has encountered some exception
while serving the request.
HTTP - Response Codes (cont..)
What else can we expect from proper REST APIs?
Pagination:
Return subset of all the data present in DB. User must be able to tell you get
me next 20 records after 60.
This can be achieved by adding offset and limit parameters to our GET APIs.
ex. /v1/tasks?offset=60&limit=20
Multiple Representation Formats:
Server must return the data in more than one format (XML, JSON etc).
For client to specify what format the server should reply, ACCEPT http
request header needs to be set. Ex. ACCEPT : Application/xml.
For server to specify what format is being used in the response format,
Content-Type http response header needs to be set.
Ex. Content-Type : Application/xml.
What else can we expect from proper REST APIs?
(Cont..)
Filtering based on parameters:
Filtering acts as a WHERE clause in SQL statement. To get all tasks whose
completion date is 1sy May 2013.
ex. /v1/tasks?completion-date=2013-05-01
Ordering:
This play a role of OrderBy clause in SQL statement. To get all the tasks
sorted by priority.
ex. /v1/tasks?order_by=priority - Sorts in ascending order of priority.
/v1/tasks?order_by=-priority - Sorts in descending order of priority.
Lets see a quick demo to understand how we can implement REST APIs in
django.
Thanks for listening :)
email - tanwanirahul@gmail.com
linkedin - in.linkedin.com/in/tanwanirahul
skype - tanwanirahul

More Related Content

What's hot

Application server
Application serverApplication server
Application server
nava rathna
 
SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)
Kashif Imran
 
Spring tutorial
Spring tutorialSpring tutorial
Spring tutorial
Sanjoy Kumer Deb
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST API
Rob Windsor
 
Intro to flask2
Intro to flask2Intro to flask2
Intro to flask2
Mohamed Essam
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WS
Katrien Verbert
 
Rest API and Client OM for Developer
Rest API and Client OM for DeveloperRest API and Client OM for Developer
Rest API and Client OM for Developer
InnoTech
 
Siebel Web Service
Siebel Web ServiceSiebel Web Service
Siebel Web Service
NAVINKUMAR RAI
 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustions
than sare
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
Arun Gupta
 
Intro To Asp
Intro To AspIntro To Asp
Intro To Asp
Adil Jafri
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
Fahad Golra
 
Oracle OSB Tutorial 3
Oracle OSB Tutorial 3Oracle OSB Tutorial 3
Oracle OSB Tutorial 3
Rakesh Gujjarlapudi
 
Java API for XML Web Services (JAX-WS)
Java API for XML Web Services (JAX-WS)Java API for XML Web Services (JAX-WS)
Java API for XML Web Services (JAX-WS)
Peter R. Egli
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
Lorna Mitchell
 
Create Home Directories on Storage Using WFA and ServiceNow integration
Create Home Directories on Storage Using WFA and ServiceNow integrationCreate Home Directories on Storage Using WFA and ServiceNow integration
Create Home Directories on Storage Using WFA and ServiceNow integration
Rutul Shah
 
Mule webservices in detail
Mule webservices in detailMule webservices in detail
Mule webservices in detail
Shahid Shaik
 
PDFArticle
PDFArticlePDFArticle
PDFArticle
Akhil Mittal
 
Enterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable ApplicationsEnterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable Applications
Gordon Dickens
 
Top 50 MuleSoft interview questions
Top 50 MuleSoft interview questionsTop 50 MuleSoft interview questions
Top 50 MuleSoft interview questions
techievarsity
 

What's hot (20)

Application server
Application serverApplication server
Application server
 
SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)
 
Spring tutorial
Spring tutorialSpring tutorial
Spring tutorial
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST API
 
Intro to flask2
Intro to flask2Intro to flask2
Intro to flask2
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WS
 
Rest API and Client OM for Developer
Rest API and Client OM for DeveloperRest API and Client OM for Developer
Rest API and Client OM for Developer
 
Siebel Web Service
Siebel Web ServiceSiebel Web Service
Siebel Web Service
 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustions
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
Intro To Asp
Intro To AspIntro To Asp
Intro To Asp
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
 
Oracle OSB Tutorial 3
Oracle OSB Tutorial 3Oracle OSB Tutorial 3
Oracle OSB Tutorial 3
 
Java API for XML Web Services (JAX-WS)
Java API for XML Web Services (JAX-WS)Java API for XML Web Services (JAX-WS)
Java API for XML Web Services (JAX-WS)
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
Create Home Directories on Storage Using WFA and ServiceNow integration
Create Home Directories on Storage Using WFA and ServiceNow integrationCreate Home Directories on Storage Using WFA and ServiceNow integration
Create Home Directories on Storage Using WFA and ServiceNow integration
 
Mule webservices in detail
Mule webservices in detailMule webservices in detail
Mule webservices in detail
 
PDFArticle
PDFArticlePDFArticle
PDFArticle
 
Enterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable ApplicationsEnterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable Applications
 
Top 50 MuleSoft interview questions
Top 50 MuleSoft interview questionsTop 50 MuleSoft interview questions
Top 50 MuleSoft interview questions
 

Viewers also liked

Apache Maven
Apache MavenApache Maven
Apache Maven
Rahul Tanwani
 
Autenticazione delle api con jwt e symfony (Italian)
Autenticazione delle api con jwt e symfony (Italian)Autenticazione delle api con jwt e symfony (Italian)
Autenticazione delle api con jwt e symfony (Italian)
Marco Albarelli
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
Building a documented RESTful API in just a few hours with Symfony
Building a documented RESTful API in just a few hours with SymfonyBuilding a documented RESTful API in just a few hours with Symfony
Building a documented RESTful API in just a few hours with Symfony
olrandir
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
Sumy PHP User Grpoup
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
Sumy PHP User Grpoup
 
A high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTSA high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTS
Smile I.T is open
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
Leonardo Proietti
 
Présentation sur l'accessibilité numérique / Evènement université de Lille 3
Présentation sur l'accessibilité numérique / Evènement université de Lille 3 Présentation sur l'accessibilité numérique / Evènement université de Lille 3
Présentation sur l'accessibilité numérique / Evènement université de Lille 3
Smile I.T is open
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Ryan Weaver
 
30 Symfony Best Practices
30 Symfony Best Practices30 Symfony Best Practices
30 Symfony Best Practices
Nicolas Perriault
 
Symfony in microservice architecture
Symfony in microservice architectureSymfony in microservice architecture
Symfony in microservice architecture
Daniele D'Angeli
 
Creating hypermedia APIs in a few minutes using the API Platform framework
Creating hypermedia APIs in a few minutes using the API Platform frameworkCreating hypermedia APIs in a few minutes using the API Platform framework
Creating hypermedia APIs in a few minutes using the API Platform framework
Les-Tilleuls.coop
 
Symfony: Your Next Microframework (SymfonyCon 2015)
Symfony: Your Next Microframework (SymfonyCon 2015)Symfony: Your Next Microframework (SymfonyCon 2015)
Symfony: Your Next Microframework (SymfonyCon 2015)
Ryan Weaver
 
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
Javier Eguiluz
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
Javier Eguiluz
 

Viewers also liked (16)

Apache Maven
Apache MavenApache Maven
Apache Maven
 
Autenticazione delle api con jwt e symfony (Italian)
Autenticazione delle api con jwt e symfony (Italian)Autenticazione delle api con jwt e symfony (Italian)
Autenticazione delle api con jwt e symfony (Italian)
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
Building a documented RESTful API in just a few hours with Symfony
Building a documented RESTful API in just a few hours with SymfonyBuilding a documented RESTful API in just a few hours with Symfony
Building a documented RESTful API in just a few hours with Symfony
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 
A high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTSA high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTS
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
 
Présentation sur l'accessibilité numérique / Evènement université de Lille 3
Présentation sur l'accessibilité numérique / Evènement université de Lille 3 Présentation sur l'accessibilité numérique / Evènement université de Lille 3
Présentation sur l'accessibilité numérique / Evènement université de Lille 3
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
 
30 Symfony Best Practices
30 Symfony Best Practices30 Symfony Best Practices
30 Symfony Best Practices
 
Symfony in microservice architecture
Symfony in microservice architectureSymfony in microservice architecture
Symfony in microservice architecture
 
Creating hypermedia APIs in a few minutes using the API Platform framework
Creating hypermedia APIs in a few minutes using the API Platform frameworkCreating hypermedia APIs in a few minutes using the API Platform framework
Creating hypermedia APIs in a few minutes using the API Platform framework
 
Symfony: Your Next Microframework (SymfonyCon 2015)
Symfony: Your Next Microframework (SymfonyCon 2015)Symfony: Your Next Microframework (SymfonyCon 2015)
Symfony: Your Next Microframework (SymfonyCon 2015)
 
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 

Similar to Http and REST APIs.

Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle
Gaurav Bhardwaj
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
Techglyphs
 
07 restful webservices design
07 restful webservices design07 restful webservices design
07 restful webservices design
Ahmed Elbassel
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API frameworkSFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
South Tyrol Free Software Conference
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptx
SUFYAN SATTAR
 
servlet 2.5 & JSP 2.0
servlet 2.5 & JSP 2.0servlet 2.5 & JSP 2.0
servlet 2.5 & JSP 2.0
megrhi haikel
 
Basics Of Servlet
Basics Of ServletBasics Of Servlet
Basics Of Servlet
Shubhani Jain
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
Rob Tweed
 
Semantic Web Servers
Semantic Web ServersSemantic Web Servers
Semantic Web Servers
webhostingguy
 
Express node js
Express node jsExpress node js
Express node js
Yashprit Singh
 
Services - Leo Tot
Services - Leo TotServices - Leo Tot
Play with force.com metadata
Play with force.com metadataPlay with force.com metadata
Play with force.com metadata
Rakesh Kumar Kedia
 
Application server vs Web Server
Application server vs Web ServerApplication server vs Web Server
Application server vs Web Server
Gagandeep Singh
 
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
Ulf Wendel
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
skill-guru
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
Tanmoy Barman
 
Design Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyDesign Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John Hardy
ManageIQ
 
Webservices Testing PPT.pdf
Webservices Testing PPT.pdfWebservices Testing PPT.pdf
Webservices Testing PPT.pdf
AbhishekDhotre4
 
Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)
Mindfire Solutions
 

Similar to Http and REST APIs. (20)

Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle Pinterest like site using REST and Bottle
Pinterest like site using REST and Bottle
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
07 restful webservices design
07 restful webservices design07 restful webservices design
07 restful webservices design
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API frameworkSFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptx
 
servlet 2.5 & JSP 2.0
servlet 2.5 & JSP 2.0servlet 2.5 & JSP 2.0
servlet 2.5 & JSP 2.0
 
Basics Of Servlet
Basics Of ServletBasics Of Servlet
Basics Of Servlet
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
 
Semantic Web Servers
Semantic Web ServersSemantic Web Servers
Semantic Web Servers
 
Express node js
Express node jsExpress node js
Express node js
 
Services - Leo Tot
Services - Leo TotServices - Leo Tot
Services - Leo Tot
 
Play with force.com metadata
Play with force.com metadataPlay with force.com metadata
Play with force.com metadata
 
Application server vs Web Server
Application server vs Web ServerApplication server vs Web Server
Application server vs Web Server
 
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
Design Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyDesign Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John Hardy
 
Webservices Testing PPT.pdf
Webservices Testing PPT.pdfWebservices Testing PPT.pdf
Webservices Testing PPT.pdf
 
Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)
 

Recently uploaded

GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 

Recently uploaded (20)

GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 

Http and REST APIs.

  • 2. Web Application Architecture {MVC} Presentation Layer Business Layer Data Access Layer (SQL or ORM) DB Takes care of Content Representation. (HTML5, CSS3). Computational Logic on data using language libraries. Access data from DB using RAW SQL queries or an ORM Data Storage System (SQLite, MySQL, ORACLE).
  • 3. Presentation Layer Business Layer Web and Mobile App - Sharing the same DB. Data Access Layer (SQL or ORM) DB Presentation Layer Business Layer Data Access Layer (SQL or ORM) Web App Mobile App MySQL Web - HTML5 & CSS3 Mobile - Native GUI Libraries Some part may repeat and some may be unique. Will be the same. What's Different? DRY - Do not Repeat Yourself Lets combine the common logic into a single layer that both apps can leverage.
  • 4. Web Service(s) Layer.. Presentation Layer Business Layer DB MySQL Presentation Layer Web App Mobile App Business Layer HTTP Communication (URLified) Exposing data in the form of APIs. Notes: Data access logic and common business logic is segregated into a new layer. Job of this layer is to get the data from data sources and expose it to applications. To access data, applications make HTTP request to a particular URL, and gets back the required data as response. WSL, can be thought of as an API driven SQL Engine, which in addition to expose data, allows applications to Create (Insert) new data into the system. Web Service(s) Layer
  • 5. So, What are web services anyway? Web services can be thought of as web application that is intended to be used by Machines (Computers, Mobiles or any other device) as opposed to humans. Philosophically, they can be described as Webified SQL engine, that allows client applications to make queries, insert new data, update or delete existing data. Design Approaches: Traditional Way - SOAP based web services (SOAP, WSDL, UDDI, WS*) Today's Way - REST based APIs. Web application intended to be used by machines.
  • 6. Application consuming data through APIs. How does this all fall into work? Web Service(s) Layer DB MySQL HTTP Request & Response /v1/task s Json data Presentation Logic Data Management & May be some business logic. HTTP Various Applications Single Data Access & Management layer.
  • 7. Designing URL endpoints for our APIs Requirement - Use Case Possible URL To get all the tasks /v1/get-all-tasks To get a particular task /v1/get-task/{id} To create a task /v1/create-task To delete a task /v1/delete-task/{id} To update a task /v1/update-task/{id} To get all tasks for a particular user /v1/get-tasks-for-users/{userId} We may iterate over these APIs to see if we can improve... Before understanding REST, lets design URI endpoints for an hypothetical application to track tasks and their associated users.
  • 8. SO, What's REST? Representational State Transfer. (You don't need to remember :) ) In simple terms, server will return representation of state of the resource. Representation may include data in XML, JSON or any other format. REST is resource oriented architecture. Everything revolves around resources. What is resource? Resource is any entity that you may want to expose and that can be named. Typically, Each entity in ER-Diagram can be thought of as a resource. In our application, we may have resources such as - Tasks and Users. Don't worry, we shall see the practicals shortly.
  • 9. REST guidelines (Principles) 2 URI's per resource. 1. Listing (collection) - /v1/tasks 2. Detail - /v1/tasks/{id} Use nouns instead of verbs to name resources.So, instead of saying /v1/getAllTasks, we should say /v1/tasks. This means, we need to revise all our URIs to follow rest principles. Prefer plurals over singular:/tasks over /task. Huh..we might need to Redo our work... :( Lets redesign our URI endpoints to follow REST principles. For associations: /resource/{id}/resourceIn our case, we may have /user/8908/tasks, to get all the tasks for a user.
  • 10. So, we are making progress in the right way now.. RESTified APIs (URL endpoints)... Requirement - Use Case Possible URLs REST based URLs To get all the tasks /v1/get-all-tasks /v1/tasks To get a particular task /v1/get-task/{id} /v1/tasks/{id} To create a task /v1/create-task/{id} /v1/tasks/ To delete a task /v1/delete-task/{id} /v1/tasks/{id} To update a task /v1/update-task /v1/tasks/{id} To get all tasks for a particular user /v1/get-tasks-for- users/{userId} /v1/users/{id}/tasks Lets iterate over our APIs to see if we can apply REST principles on it.. How will the server know when to create, update or delete.. Lets find it out..
  • 11. CRUD operations on REST APIs. Telling server what action to perform.. HTTP provides request methods, that tells server what action to perform on a URI. HTTP provides methods that can be directly mapped to RDBMS CRUD Operation. These methods include - GET, POST, PUT, DELETE. Hmm..Lets see how our APIs should respond to these methods.
  • 12. Resource POST (Create) GET (Read) PUT (Update) DELETE (Delete) /tasks Create a new task Return all tasks Replace all tasks with new tasks. Delete all tasks /tasks/123 Create a task inside another task. Return a specific task Update this task if exist or create a new one. Delete this task. Responding to various HTTP methods.. Needs to be handled with care. (We may not implement them) Well, this seems great..but how do applications come to know if their request succeeded or anything went wrong. (Specially for PUT and POST)? Lets dig into HTTP to see if we can find an answer...
  • 13. HTTP - Response Codes Server sends response code for every client request. This communicates to clients what happened to the their request (Pass, fail, error etc). Response code for each type of request Range (From client perspective) Status code Method Comments. 1XX (100 - 199) * - Informational * Request is accepted and is in progress 2xx (200 - 299) - Success 200 - OK GET Request is served. 201 - Created POST / PUT Whenever a server create new resource on client's request 202 - Accepted * Server accepted the requested but will be processed later. 204 - No Content PUT Server performed the request but has no data to return.
  • 14. Range (From client perspective) Status code Method Comments. 3XX - Redirection 301 - Permanently moved GET Server redirects client to the new URL of the same resource. 4xx (400 - 499) - Client Side Problem 400 - Bad Request. * Client has used either wrong URL or parameters, or provided insufficient data in the request. 401 - Unauthorized. * Client is unauthorized to make this request. (May be client have passed wrong credentials) 404 - Not Found GET The request resource cannot be found. 5xx (500 - 599) - Server Side Problem 500 - internal server error. * Server has encountered some exception while serving the request. HTTP - Response Codes (cont..)
  • 15. What else can we expect from proper REST APIs? Pagination: Return subset of all the data present in DB. User must be able to tell you get me next 20 records after 60. This can be achieved by adding offset and limit parameters to our GET APIs. ex. /v1/tasks?offset=60&limit=20 Multiple Representation Formats: Server must return the data in more than one format (XML, JSON etc). For client to specify what format the server should reply, ACCEPT http request header needs to be set. Ex. ACCEPT : Application/xml. For server to specify what format is being used in the response format, Content-Type http response header needs to be set. Ex. Content-Type : Application/xml.
  • 16. What else can we expect from proper REST APIs? (Cont..) Filtering based on parameters: Filtering acts as a WHERE clause in SQL statement. To get all tasks whose completion date is 1sy May 2013. ex. /v1/tasks?completion-date=2013-05-01 Ordering: This play a role of OrderBy clause in SQL statement. To get all the tasks sorted by priority. ex. /v1/tasks?order_by=priority - Sorts in ascending order of priority. /v1/tasks?order_by=-priority - Sorts in descending order of priority. Lets see a quick demo to understand how we can implement REST APIs in django.
  • 17. Thanks for listening :) email - tanwanirahul@gmail.com linkedin - in.linkedin.com/in/tanwanirahul skype - tanwanirahul