SlideShare a Scribd company logo
Advanced Web Development in PHP
Module VIII: Understanding REST
API
Rasan Samarasinghe
ESOFT Computer Studies (pvt) Ltd.
No 68/1, Main Street, Embilipitiya.
Contents
1. What is an API?
2. Comparing a website to an API
3. Classification of APIs
4. What is REST API?
5. What model does REST use?
6. REST HTTP Methods
7. HTTP Codes
8. The advantages of REST
9. What is CRUD?
10. CRUD Operations
11. CRUD Application Example
12. REST API Implementation
13. Folders and Files Structure
14. MySQL Database
15. Reading all Products
16. Reading one Product
17. Creating a Product
18. Updating a Product
19. Deleting a Product
20. Searching a Product
What is an API?
• API stands for Application Programming Interface.
• API’s basically allow your product or service to talk to
another product or service.
• Software-to-software interaction, not user interaction.
• They are used to give people access to your
data/resources from outside the firewall.
• This means opening up your product’s data and
functionality to other developers both internally and
externally.
Comparing a website to an API
Compare
GitHub Website
https://github.com/rasansmn
GitHub API
https://api.github.com/users/rasansmn
Classification of APIs
Web Service API
• SOAP
• XML-RPC and JSON-RPC
• REST
WebSocket APIs
Library-based APIs
• JavaScript
• TWAIN
Class-based APIs (Object
Orientation)
• Java API
• Android API
OS Functions and Routines
• Access to file system
• Access to user interface
Object Remoting APIs
• CORBA
• .NET Remoting
Hardware APIs
• Video acceleration
• Hard disk drives
• PCI buses
What is REST API?
• REST stands for Representational State Transfer.
• It is a lighter weight alternative to SOAP and WSDL
XML-based API protocols.
What model does REST use?
• REST uses a client-server model, where the server
is an HTTP server and the client sends HTTP verbs
(GET, POST, PUT, DELETE), along with a URL and
variable parameters that are URL-encoded.
• The URL describes the object to act upon and the
server replies with a result code and valid
JavaScript Object Notation (JSON).
What model does REST use?
REST HTTP Methods
Method Description
GET Request to read a webpage
HEAD Request to read a webpage’s header
PUT Request to store a webpage
POST Append to a names resource
DELETE Remove the webpage
TRACE Echo the incoming request
CONNECT Reserved for future use
OPTIONS Query certain options
HTTP Codes
• 200 - “OK”.
• 201 - “Created” (Used with POST).
• 400 - “Bad Request” (Perhaps missing required parameters).
• 401 - “Unauthorized” (Missing authentication parameters).
• 403 - “Forbidden” (You were authenticated but lacking required
privileges).
• 404 - “Not Found”.
The advantages of REST
• Separation between the client and the server.
• Visibility, reliability and scalability.
• The REST API is always independent of the type of
platform or languages.
• Lighter weight alternative to SOAP and WSDL
XML-based API protocols.
What is CRUD?
The CRUD acronym is often used to describe
database operations. CRUD stands for CREATE,
READ, UPDATE, and DELETE.
CRUD Operations
• POST: A client wants to insert or create an object.
• GET: A client wants to read an object.
• PUT: A client wants to update an object.
• DELETE: A client wants to delete an object.
CRUD Application Example
Simple REST API Implementation in PHP
REST API objects and their operations
• Products
– Read (all records)
– Read one
– Create
– Update
– Delete
– Search
• Categories
– Read (all records)
– Other operations has to be implemented as an exercise
Web root Folders and Files Structure
MySQL Database
Import MySQL database using api_db.sql dump file
Reading all Products
Using PostMan as the client to read all products
Reading one Product
Using PostMan as the client to read one product
Creating a Product
Using PostMan as the client to create a product
Updating a Product
Using PostMan as the client to update a product
Deleting a Product
Using PostMan as the client to delete a product
Searching a Product
Using PostMan as the client to search a product
The End
http://twitter.com/rasansmn

More Related Content

What's hot (20)

PPTX
Typescript ppt
akhilsreyas
 
PDF
SOAP-based Web Services
Katrien Verbert
 
PDF
React lecture
Christoffer Noring
 
PPTX
Advance Java Topics (J2EE)
slire
 
PPTX
OOP Introduction with java programming language
Md.Al-imran Roton
 
PPTX
Intro to React
Justin Reock
 
PPTX
JavaScript Promises
L&T Technology Services Limited
 
PPTX
Restful web services ppt
OECLIB Odisha Electronics Control Library
 
PPTX
React hooks
Ramy ElBasyouni
 
PPTX
Introduction to REST - API
Chetan Gadodia
 
PPTX
Object Oriented Programming In JavaScript
Forziatech
 
PDF
Use Node.js to create a REST API
Fabien Vauchelles
 
PPT
Advanced Javascript
Adieu
 
PDF
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
PDF
ES6 presentation
ritika1
 
PDF
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
PDF
Introduction into ES6 JavaScript.
boyney123
 
PPTX
ASP.NET Core MVC + Web API with Overview
Shahed Chowdhuri
 
PDF
Angular and The Case for RxJS
Sandi Barr
 
PPTX
An Introduction To REST API
Aniruddh Bhilvare
 
Typescript ppt
akhilsreyas
 
SOAP-based Web Services
Katrien Verbert
 
React lecture
Christoffer Noring
 
Advance Java Topics (J2EE)
slire
 
OOP Introduction with java programming language
Md.Al-imran Roton
 
Intro to React
Justin Reock
 
JavaScript Promises
L&T Technology Services Limited
 
React hooks
Ramy ElBasyouni
 
Introduction to REST - API
Chetan Gadodia
 
Object Oriented Programming In JavaScript
Forziatech
 
Use Node.js to create a REST API
Fabien Vauchelles
 
Advanced Javascript
Adieu
 
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
ES6 presentation
ritika1
 
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
Introduction into ES6 JavaScript.
boyney123
 
ASP.NET Core MVC + Web API with Overview
Shahed Chowdhuri
 
Angular and The Case for RxJS
Sandi Barr
 
An Introduction To REST API
Aniruddh Bhilvare
 

Similar to Advanced Web Development in PHP - Understanding REST API (20)

PDF
REST API and CRUD
Prem Sanil
 
PPTX
Apitesting.pptx
NamanVerma88
 
PPTX
advanced computer network, about computer
jishukurmi81
 
PPTX
Introduction to APIs (Application Programming Interface)
Vibhawa Nirmal
 
PDF
Introduction to REST - REST Basics - JSON
Matrix823409
 
PDF
zendframework2 restful
tom_li
 
PPTX
What is an API?
Muhammad Zuhdi
 
PDF
Applicaton Development using RESTful APIs
Sourav Maji
 
PDF
API Basics
Ritul Chaudhary
 
PDF
Web APIs
Carlos Santos
 
PDF
Ebook undisturbed rest-v1 [res_tful apis]
johnkbutcher
 
PPTX
introduction about REST API
AmilaSilva13
 
PPTX
API Development Essentials: REST, SOAP, GraphQL Explained
ankitraj5ar
 
PPTX
REST API
Kanushka Gayan
 
PDF
What is API - Understanding API Simplified
Jubin Aghara
 
PDF
IRJET- Rest API for E-Commerce Site
IRJET Journal
 
PPTX
Distributed systems air traffic controller
nazimsattar
 
PPTX
rest-api-basics.pptx
AgungSutikno1
 
PDF
Coding 100-session-slides
Cisco DevNet
 
PPTX
REST API
Tofazzal Ahmed
 
REST API and CRUD
Prem Sanil
 
Apitesting.pptx
NamanVerma88
 
advanced computer network, about computer
jishukurmi81
 
Introduction to APIs (Application Programming Interface)
Vibhawa Nirmal
 
Introduction to REST - REST Basics - JSON
Matrix823409
 
zendframework2 restful
tom_li
 
What is an API?
Muhammad Zuhdi
 
Applicaton Development using RESTful APIs
Sourav Maji
 
API Basics
Ritul Chaudhary
 
Web APIs
Carlos Santos
 
Ebook undisturbed rest-v1 [res_tful apis]
johnkbutcher
 
introduction about REST API
AmilaSilva13
 
API Development Essentials: REST, SOAP, GraphQL Explained
ankitraj5ar
 
REST API
Kanushka Gayan
 
What is API - Understanding API Simplified
Jubin Aghara
 
IRJET- Rest API for E-Commerce Site
IRJET Journal
 
Distributed systems air traffic controller
nazimsattar
 
rest-api-basics.pptx
AgungSutikno1
 
Coding 100-session-slides
Cisco DevNet
 
REST API
Tofazzal Ahmed
 
Ad

More from Rasan Samarasinghe (20)

PPTX
Managing the under performance in projects.pptx
Rasan Samarasinghe
 
PPTX
Agile project management with scrum
Rasan Samarasinghe
 
PPTX
Introduction to Agile
Rasan Samarasinghe
 
PPSX
IT Introduction (en)
Rasan Samarasinghe
 
PPSX
Application of Unified Modelling Language
Rasan Samarasinghe
 
PPSX
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Rasan Samarasinghe
 
PPSX
Advanced Web Development in PHP - Code Versioning and Branching with Git
Rasan Samarasinghe
 
PPSX
DIWE - Working with MySQL Databases
Rasan Samarasinghe
 
PPSX
DIWE - Using Extensions and Image Manipulation
Rasan Samarasinghe
 
PPSX
DIWE - File handling with PHP
Rasan Samarasinghe
 
PPSX
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
 
PPSX
DIWE - Fundamentals of PHP
Rasan Samarasinghe
 
PPSX
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
PPSX
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
 
PPSX
DIWE - Multimedia Technologies
Rasan Samarasinghe
 
PPSX
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
 
PPSX
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
PPSX
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
 
PPSX
DISE - Software Testing and Quality Management
Rasan Samarasinghe
 
PPSX
DISE - Introduction to Project Management
Rasan Samarasinghe
 
Managing the under performance in projects.pptx
Rasan Samarasinghe
 
Agile project management with scrum
Rasan Samarasinghe
 
Introduction to Agile
Rasan Samarasinghe
 
IT Introduction (en)
Rasan Samarasinghe
 
Application of Unified Modelling Language
Rasan Samarasinghe
 
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Rasan Samarasinghe
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Rasan Samarasinghe
 
DIWE - Working with MySQL Databases
Rasan Samarasinghe
 
DIWE - Using Extensions and Image Manipulation
Rasan Samarasinghe
 
DIWE - File handling with PHP
Rasan Samarasinghe
 
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
 
DIWE - Fundamentals of PHP
Rasan Samarasinghe
 
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
 
DIWE - Multimedia Technologies
Rasan Samarasinghe
 
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
 
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
 
DISE - Software Testing and Quality Management
Rasan Samarasinghe
 
DISE - Introduction to Project Management
Rasan Samarasinghe
 
Ad

Recently uploaded (20)

PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Digital Circuits, important subject in CS
contactparinay1
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 

Advanced Web Development in PHP - Understanding REST API

  • 1. Advanced Web Development in PHP Module VIII: Understanding REST API Rasan Samarasinghe ESOFT Computer Studies (pvt) Ltd. No 68/1, Main Street, Embilipitiya.
  • 2. Contents 1. What is an API? 2. Comparing a website to an API 3. Classification of APIs 4. What is REST API? 5. What model does REST use? 6. REST HTTP Methods 7. HTTP Codes 8. The advantages of REST 9. What is CRUD? 10. CRUD Operations 11. CRUD Application Example 12. REST API Implementation 13. Folders and Files Structure 14. MySQL Database 15. Reading all Products 16. Reading one Product 17. Creating a Product 18. Updating a Product 19. Deleting a Product 20. Searching a Product
  • 3. What is an API? • API stands for Application Programming Interface. • API’s basically allow your product or service to talk to another product or service. • Software-to-software interaction, not user interaction. • They are used to give people access to your data/resources from outside the firewall. • This means opening up your product’s data and functionality to other developers both internally and externally.
  • 6. Classification of APIs Web Service API • SOAP • XML-RPC and JSON-RPC • REST WebSocket APIs Library-based APIs • JavaScript • TWAIN Class-based APIs (Object Orientation) • Java API • Android API OS Functions and Routines • Access to file system • Access to user interface Object Remoting APIs • CORBA • .NET Remoting Hardware APIs • Video acceleration • Hard disk drives • PCI buses
  • 7. What is REST API? • REST stands for Representational State Transfer. • It is a lighter weight alternative to SOAP and WSDL XML-based API protocols.
  • 8. What model does REST use? • REST uses a client-server model, where the server is an HTTP server and the client sends HTTP verbs (GET, POST, PUT, DELETE), along with a URL and variable parameters that are URL-encoded. • The URL describes the object to act upon and the server replies with a result code and valid JavaScript Object Notation (JSON).
  • 9. What model does REST use?
  • 10. REST HTTP Methods Method Description GET Request to read a webpage HEAD Request to read a webpage’s header PUT Request to store a webpage POST Append to a names resource DELETE Remove the webpage TRACE Echo the incoming request CONNECT Reserved for future use OPTIONS Query certain options
  • 11. HTTP Codes • 200 - “OK”. • 201 - “Created” (Used with POST). • 400 - “Bad Request” (Perhaps missing required parameters). • 401 - “Unauthorized” (Missing authentication parameters). • 403 - “Forbidden” (You were authenticated but lacking required privileges). • 404 - “Not Found”.
  • 12. The advantages of REST • Separation between the client and the server. • Visibility, reliability and scalability. • The REST API is always independent of the type of platform or languages. • Lighter weight alternative to SOAP and WSDL XML-based API protocols.
  • 13. What is CRUD? The CRUD acronym is often used to describe database operations. CRUD stands for CREATE, READ, UPDATE, and DELETE.
  • 14. CRUD Operations • POST: A client wants to insert or create an object. • GET: A client wants to read an object. • PUT: A client wants to update an object. • DELETE: A client wants to delete an object.
  • 16. Simple REST API Implementation in PHP REST API objects and their operations • Products – Read (all records) – Read one – Create – Update – Delete – Search • Categories – Read (all records) – Other operations has to be implemented as an exercise
  • 17. Web root Folders and Files Structure
  • 18. MySQL Database Import MySQL database using api_db.sql dump file
  • 19. Reading all Products Using PostMan as the client to read all products
  • 20. Reading one Product Using PostMan as the client to read one product
  • 21. Creating a Product Using PostMan as the client to create a product
  • 22. Updating a Product Using PostMan as the client to update a product
  • 23. Deleting a Product Using PostMan as the client to delete a product
  • 24. Searching a Product Using PostMan as the client to search a product