Friday, 24 May 2019

REST APIs, SOAP vs REST APIs, REST APIs Smackdown!

rest apis example
REST APIs Tutorial

APIs are a trending topic, energetically debated by business-people, IT managers, and developers alike. In this tutorial, I'll describe the REST APIs (Application Programming Interface). So let's look at an overview of REST API. 


What is REST APIs?


REST stands for REpresentational State Transfer APIs. REST APIs are an architectural style defined to help create and organize distributed systems. REST, however, is the newcomer on the block and for web service access protocols. REST APIs objective is to provide a truly simple, lightweight method for accessing web services.

History of REST APIs.


Roy Fielding an American computer scientist has made tremendous contributions to the IT Industry, especially regarding the Internet, but according to my perception, his research thesis is the thing that received the most attention and highlights his name among a lot of people who otherwise wouldn't have heard of him.

He was born in 1965 and he is one of the main authors of the HTTP protocol, the protocol that the entire Web infrastructure is based on. 

In the year 2000, Fielding presented his doctoral dissertation, Architectural Styles and the Design of Network-based Software Architecture. In its, he coined the term REST, an architectural style for distributed hypermedia systems.

REST APIs Tasks.


Let's look at some REST API tasks. The most REST (Representational State Transfer) services or most web services that are using REST APIs rely exclusively on obtaining the needed information using a URL. Therefore, REST APIs can use four different HTTP verbs to perform tasks.

  1. GET, which is used to retrieve it.
  2. POST, which can be used to create. 
  3. PUT, which can be used to update. 
  4. DELETE, which is used to delete. 


JSON
REST APIs Architecture 

JSON stands for JavaScript Object Notation. JSON is a simple and language-independent way of formatting programming language data structures (numbers, arrays, hashes, and so on) as strings. JSON makes a lightweight alternative to XML-based approaches to data serialization, like XML Schema.

Example of JSON Feed. 

{
    "id": 10,
    "name": "A Black Table",
    "price": 42.80,
    "tags": ["Office", "Garden"]
}
-

SOAP vs REST.


The Simple Object Access Protocol or SOAP and Representational State Transfer or REST are two answers to essentially the same question. 
  • SOAP is a standards-based web services protocol that's been around for a while. And it enjoys all the benefits of long-term use. It was originally developed by Microsoft. And it's not as simple as it may sound. 
  • REST, however, is the newcomer on the block and for web service access protocols. And it aims to address SOAP's shortcomings. Its aim is really to provide a truly simple, lightweight method for accessing web services.
Many developers found working with SOAP cumbersome and hard to use. 

For example, working with SOAP in JavaScript meant writing a ton of code to perform extremely simple tasks because you'd have to create the required XML structure absolutely every time. 

So to simplify that, REST relies on a simple URL, in most cases, as opposed to any kind of complex XML structuring. 

So unlike SOAP, REST doesn't have to use XML to provide the response. So you can find REST-based services that output the data in command-separated values or CSVs, JavaScript Object Notation, JSON, or in RSS, Really Simple Syndication. So the point is that you can obtain the output you need in a form that's easy to parse within the language you need for your application using REST.

REST API Advantages over SOAP.


Now, let's look at REST's API advantages over SOAP.
  • REST is easier to use for the most part and it's more flexible. It's got some advantages. So it's designed closer to other web technologies in terms of their philosophy. 
  • REST APIs don't require expensive tools to interact with the web service. It's just a URL. It's easier to learn. It has a smaller learning curve. And it's fast because there's no excessive programming or processing required. 
  • It's also more efficient because it uses smaller message formats in comparison to SOAP XML, which has got bloated XML message formats. So that's REST APIs.

No comments:

Post a Comment