Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Restful Api

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

RESTFUL API

PREPARED BY: 1-AHMAD OMAR


2-OMAR FALAH
3-AHMAD AZIZ
4-MAJEED OMAR
5-YAHYA MEWAN
6-ALA SAAD
01 INTRODUCTION TO RESFUL API
WHATS IS RESTFUL API AND HOW DOES IT WORK ?

02 HTTP METHODS TABLE OF


CONTENTS
WHAT ARE THE HTTP METHODS AND HOW DO THEY WORK?

03 ARCHITECTURAL CONSTRAINTS OF RESTFUL API


WHAT ARE THE ARCHITECTURAL CONSTRAINTS?

04 ADVANTAGE OF THE RESTFUL API


WHAT ARE THE ADVANTAGE OF THE RESTFUL API?
05 JSON
WHAT IS A JSON AND HOW DOES IT WORK?

06 POSTMAN TABLE OF
WHAT IS THE POSTMAN? CONTENTS
07 HTTP STATUS CODES
WHAT ARE THE HTTP STATUS CODES

08 FETCHING AND SENDING DATA IN API


HOW TO FETCH DATA FROM THE INTERNET?
01
INTRODUCTION
TO RESTFUL API
REST stands for REpresentational State
Transfer and API stands for Application
Program Interface. REST is a software
architectural style that defines the set of

WHAT IS rules to be used for creating web services.

RESTFUL API Web services which follow the REST


architectural style are known as RESTful web
AND HOW IT services. It allows requesting systems to
IS WORK? access and manipulate web resources by
using a uniform and predefined set of rules.
Interaction in REST based systems happen
through Internet’s Hypertext Transfer
Protocol (HTTP).

5
02
HTTP METHODS
HTTP METHODS: There are four main HTTP
methods that you use in REST APIs. Here’s
what each of them does:
WHAT ARE THE 1. POST: is used to send data to a server to
HTTP METHODS create/update a resource.
2. GET: is used to request data from a
AND HOW DO specified resource.
THEY WORK? 3. PUT: is used to send data to a server to
create/update a resource.
4. DELET: deletes the specified resource.
REST
API IN
ACTION
A REST client can
interact with each
resource by sending an
HTTP request.

8
03
ARCHITECTU WHAT ARE THE
ARCHITECTURAL

RAL CONSTRAINTS?

CONSTRAINT
S OF
THRER ARE
SIX
01.UNIFORM 02.STATELESS 03.CHACHABLE ARCHITECT
INTERFACE
URAL
All API requests for
the same resource
REST APIs are When possible,
resources should
CONSTRAIN
stateless, meaning
should look the that each request be cacheable on TS WHICH
the client or server
same, no matter needs to include all
the information side. MAKES ANY
where the request
comes from. necessary for WEB
processing it.
SERVICE
04.CLIENT- 05.LAYERD 06.CODE ON
SERVER SYSTEM DEMAND
In REST API In REST APIs, the REST APIs usually
design, client and calls and send static
server responses go resources, but in
applications must through different certain cases,
be completely layers. responses can
independent of also contain
each other. executable code
(such as Java
applets).
04.
ADVANTAGE WHAT ARE THE

OF RESTFUL
ADVANTAGE OF THE
RESTFUL API?

API
Automation: with APIs,
computers rather than Application: because APIs
people can manage the
work. Through APIs, 1 2 can access the app
components, the delivery of
agencies can update work services and information is
flows to make them quicker more flexible.
and more productive.

New data available:


More scope: with an API an API allows all of
an application layer can the information
be created which can be generated at the
used to distribute 3 4 government level to be
information and services available to every
to new audiences which citizen, not just a select
can be personalized to few.
create custom user
experiences.
Efficiency: when access is Personalization: through
provided to an API, the APIs any user or company
content generated can be 5 6 can customize the content
published automatically and services that they use
and is available for every the most.
channel. It allows it to be
shared and distributed
more easily.

Adaptation: needs change


Integration: APIs allow over time and APIs help to
content to be embedded anticipate changes. When
from any site or application working with this
more easily. This 7 8 technology, data migration
guarantees more fluid is supported better, and the
information delivery and an information is reviewed
integrated user experience. more closely. In short, APIs
make service provision
more flexible.
05
JSON 03

WHAT IS THE JSON AND HOW


DOES IT WORK?
JSON, or JavaScript Object Notation, is a minimal,
readable format for structuring data. It is used primarily
to transmit data between a server and web application,
as an alternative to XML. Squarespace uses JSON to
store and organize site content created with the CMS.
The two primary parts that make up JSON are keys and
values. Together they make a key/value pair.

• KEY: A key is always a string enclosed in quotation


marks.

• VALUE: A value can be a string, number, boolean


expression, array, or object.
06
POSTMAN
WHAT IS THE POSTMAN?
POSTMAN
Postman is an API
platform for building
and using APIs.
Postman simplifies
each step of the API
lifecycle and
streamlines
collaboration so you
can create better APIs
—faster.

18
EXAMPLE OF THE POSTMAN
AND JSON:
07
HTTP WHAT ARE THE HTTP STATUS

STATUS
CODES?

CODES
-HTTP defines these standard status codes that can be
used to convey the results of a client’s request. The
status codes are divided into five categories.

1. 1xx: Informational – Communicates transfer protocol-level


information.

2. 2xx: Success – Indicates that the client’s request was accepted


successfully

3. 3xx: Redirection – Indicates that the client must take some


additional action in order to complete their request.

4. 4xx: Client Error – This category of error status codes points the
finger at clients.

5. 5xx: Server Error – The server takes responsibility for these error
status codes.
08
FETCHING
AND
HOW TO FETCH DATA
FROM THE INTERNET?

SENDING
DATA IN API
ADD THE HTTP
PACKAGE:

To add the http package, open


your pubspec.yaml file and add
the http package under the
dependencies section. You can
get the latest version of http
package
on pub.dev/packages/http.

23
SENDING DATA TO
API:

We can add products to the


API using post method
from http package in
addItems() method.

24
FETCHING DATA
FROM API:

To fetch data from internet


create a function called
fetchProducts(). That function
return Future<List<Post>>.

25
DISPLAYING THE
DATA:

Then call the fetchPost()


function in the
initState().

26
THANKS!
ANY QUESTION?

You might also like