Building Web
Application
using API
Presented by:
JOSHUA ALEXES DIGNADICE
What is API?
Application Programming Interface
A way for programmers to communicate
with an application
Is a set of routines, protocols, and tools for
building software applications. The API
specifies how software components should
interact and APIs are used when
programming graphical user interface
(GUI) components.
WEB (Remote) APIs
A server-side programmatic interface allows
the client application to communicate with
the server.
Based on one or more publicly exposed
endpoints and a defined request–response
message system.
Uses the network to provide its services.
SOAP vs REST
Simple Object Access Protocol REpresentational State Transfer
is a protocol is an architectural style
uses services interfaces URL based services
Works on top of any HTTP/HTTPS only
communication Protocol, even JSON , XML, TEXT, HTML
asynchronously(TCP HTTP FTP Authorization and security must be
SMTP) implemented separately
Only XML Easy to implement
Security and authorization
arepart of the protocol
Fully described and
provideinformation to users
(WSDL)
Principles of REST
RESOURCES expose easily understood
directory structure URIs.
REPRESENTATIONS transfer JSON or XML
to represent data objects and attributes.
MESSAGES use HTTP methods explicitly (for
example, GET, POST, PUT, and DELETE).
STATELESS interactions store no client
context on the server between requests. The
client holds session state
What is request and response cycle?
THE REQUEST/RESPONSE CYCLE
TRACES HOW A USER'S REQUEST
FLOWS THROUGH THE APP.
UNDERSTANDING THE
REQUEST/RESPONSE CYCLE IS
HELPFUL TO FIGURE OUT WHICH
FILES TO EDIT WHEN DEVELOPING
AN APP (AND WHERE TO LOOK
WHEN THINGS AREN'T WORKING).
CRUD - HTTP request in REST
HTTP Request DB Operations
GET SELECT rows
POST INSERT new row
PUT UPDATE row
DELETE DELETE row
PATCH UPDATE certain field
Request and Response Cycle
HTTP request status code
Indicate the result of the HTTP request.
1XX - informational
2XX – success (200 -OK, 201 – Created,204 -
No Content)
3XX - redirection
4XX - client error (400-Bad Request, 401
Unauthorized, Forbidden, PNF)
5XX - server error
What is JSON?
Stands for JavaScript Object Notation.
Is lightweight format for exchanging data
between the client and server.
Easy for humans to read and write.
Easy for machines to parse and generate.
Often used in Ajax applications due to:
-Its simplicity
-Its format which is based in JavaScript
object literals
How to parse data as JSON?
JSON parsing is the process of
converting a JSON object in text
format to a Javascript object that can
be used inside a program. In Javascript,
the standard way to do this is by using
the method JSON. parse() , as the
Javascript standard specifies.
Demo
Code Editor API Testing Tools Free API Endpoint API Integration Tool