rest api vs web api code example
Example 1: rest api means
Let's break it into two components:
1) RESTful
2) API
An API is an interface through which one program or web site talks to another.
They are used to share data and services, and they come in many different
formats and types.
A RESTful API is one of the many possible ways that programs, servers,
and web sites can share data and services. REST (Representational State Transfer
) describes the general rules for how the data and services are represented
through the API so that other programs will be able to correctly request and
receive the data and services that an API makes available
Example 2: rest api
1) REQUEST
2) RESPONSE
When we send request, we need to know the API
methods/endpoints that are available:
- read documentation about API methods.
- Swagger tool, that has API methods and descriptions
simple endpoint:
…school.com/api/students
Types of Requests:
GET -> Read data
POST -> Create/insert data
PUT -> Update data
DELETE-> Delete data
I send GET, POST, PUT, DELETE type of API requests to
API endpoint/method and get response.
ORDS (oracle data service) API -> HR Database
ORDS API has methods that we can send request to, and it sends
response with Data from HR database.
Example 3: api vs web services
APIs are Web services.
the specifications and cannot perform
all the tasks that APIs would perform.
of use: SOAP, REST and XML-RPC for
communication whereas API may be exposed
to in multiple ways.
to operate while APIs don’t need
a network for operation.
Example 4: API vs Web Services
1. All Web services are APIs but all APIs are not Web services.
2. Web services might not perform all the operations that an API
would perform.
3. A Web service uses only three styles of use: SOAP, REST and
XML-RPC for communication whereas API may use any style for
communication.
4. A Web service always needs a network for its operation whereas
an API doesn’t need a network for its operation.
5. An API facilitates interfacing directly with an application whereas
a Web service is a required a path.