Rest Api
Rest Api
Rest Api
➢ Today I am going to talk about the term which you people heard a lot as
Rest APIs. REST states as Representational State Transfer (REST) and is an
architectural style that uses simple HTTP calls for inter-machine
communication instead of more complex options (RPC, SOAP).
REST was built on the principles of HTTP and these Services can return types data
such as;
• XML
• JSON - (JavaScript Object Notation)
• HTML
• Plain Text
• Binary/octet (Images, PDF’s…)
HATEOAS stands for Hypertext as The Engine of Application State. It means that
hypertext should be used to find a way through the API. Note the Server responds
with a "link" tag and URL needed to complete the specified action in the GET
method.
An example:
GET /account/12345 HTTP/1.1
HTTP/1.1 200 OK
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<balance currency="usd">-25.00</balance>
<link rel="deposit" href="/account/12345/deposit" /> </account>
➢ RESTful Web services are easily leveraged by most tools, including those
that are free and inexpensive. RESTful Services are less complex, more
efficient (use smaller message format) and provide better performance than
SOAP (Simple Operation Access Protocol).
Benefits
• Extensibility
• Customizability
• Reusability
• Visibility
• Portability
• Reliability
Typical REST API calls:
HTTP is a Request/Response protocol. A client makes a Request to the Server and
the Server sends back a Response. The client builds a Request consisting of
Headers and Payload and Sends to a URL with an HTTP Method GET, PUT,
POST, HEAD, DELETE.
• GET – Retrieves a resource
• POST – Creates a resource
• PUT – Updates a resource
• DELETE – Deletes a resource
The Server builds a Response with Headers & Payload and sends it back to the
Client along with a status code validating the “response”.