Laravel API
Course Code: CSC 4182 Course Title: Advanced Programming In Web
Technologies
Dept. of Computer Science
Faculty of Science and Technology
Lecturer No: 2 Week No: 01 Semester: Summer20-21
Lecturer: Md.Al-Amin (alamin@aiub.edu)
Lecture Outline
1. API
2. Type of APIs
3. SOAP vs RESTfull
4. Laravel API
Lecture Objective
1. Understanding & practicing API
Application Programming Interface (API)
4
Application Programming
Interface (API)
According to Wikipedia: An application programming
interface (API) is a computing interface to a software component
or a system, that defines how other components or systems can
use it. It defines the kinds of calls or requests that can be made,
how to make them, the data formats that should be used, the
conventions to follow, etc. It can also provide extension
mechanisms so that users can extend existing functionality in
various ways and to varying degrees.
What is API?
Application Programming Interface (API):
A software interface used to access data, server software or other application
Usage of API
• Web based systems
• Operating systems
• Database systems
• Computer hardware
Good API = Easier Programming + Faster Integration + Scalable
How API works
How API works
Types of API
1. REST (RESTful) API
• Representational state transfer JSON format
2. SOAP
• Simple Object Access Protocol uses XML to transfer data
3. XML-RPC
• Extensible Markup Language
• Remote Procedure Calls
4. JSON-RPC
• JSON instead of XML format
REST API vs SOAP API
# Key REST API SOAP API
Rest API is implemented as it has no On other hand SOAP API has an
1 Implementation official standard at all because it is an official standard because it is a
architectural style. protocol.
Internal REST APIs uses multiple standards like SOAP APIs is largely based and uses
2 HTTP, JSON, URL, and XML for data
communication communication and transfer. only HTTP and XML.
On other hand Soap API requires
As REST API deploys and uses multiple more resource and bandwidth as it
3 Resource standards as stated above, so it takes needs to convert the data in XML
requirement fewer resources and bandwidth as
compared to SOAP API. which increases its payload and
results in the large sized file.
REST API uses Web Application
Description Language for describing On other hand SOAP API used Web
4 Description Services Description language for the
the functionalities being offered by same.
web services.
REST API vs SOAP API
# Key REST API SOAP API
On other hand SOAP has
SSL( Secure Socket Layer) and
5 Security REST has SSL and HTTPS for WS-security due to which in the
security. cases like Bank Account
Password, Card Number, etc.
SOAP is preferred over REST.
6 Abbreviation REST stands for Representational On other hand SOAP stands for
State Transfer. Simple Object Access Protocol
REST can make use of SOAP as On other hand SOAP cannot
the underlying protocol for web make use of REST since SOAP is
7 Interchange
services, because in the end it is a protocol and REST is an
just an architectural pattern. architectural pattern.
API in Laravel (get data)
Laravel can create and handle API very easily.
API routes can be found in routes/api.php
Include the controller in api.php
Create route in api.php
API in Laravel (get data)
Return data from controller Get data from the database to the
view
API in Laravel (get data)
Request data from
the web and render
Postman
Postman is an application used for API testing. It is an HTTP client
that tests HTTP requests, utilizing a graphical user interface, through
which we obtain different types of responses that need to be
subsequently validated.
Test Postman (GET)
Request data
using Postman
Data will be
returned from
database
API in Laravel (post data)
Add route in api.php
Insert data using controller
Test Postman (POST)
Insert data
from Postman
Database will
be updated
Books
PHP Advanced and Object-Oriented Programming, 3rd Edition; Larry
Ullman; Peachpit, Press, 2013
PHP Objects, Patterns and Practice, 5th Edition; Matt Zandstra; Apress,
2016
Learning PHP, MySQL, JavaScript and CSS, 2nd Edition; Robin Nixon;
O’Reilly, 2009
Eloquent JavaScript: A Modern Introduction to Programming; Marijn
Haverbeke; 2011
Learning Node.js: A Hands On Guide to Building Web Applications in
JavaScript; Marc Wandschneider; Addison-Wesley, 2013
Beginning Node.js; Basarat Ali Syed; Apress, 2014
References
1. https://www.w3schools.com/js/default.asp
2. https://www.tutorialspoint.com/javascript/index.htm
3. https://stackoverflow.com/questions/20435653/what-is-vanillajs
4. http://www.cs.ucc.ie/~gavin/javascript/
5. https://www.w3schools.com/js/default.asp
Thank You!