REST API (Part I)
State
Transfer
Application
Program
Interface
REST and API acronyms for Representational State Transfer & Application Programming Interface.
To make a sense of what REST API is and how it works ,
Imagine a library(Figure: 01) with books,a librarian,and people who want to borrow,add,update or remove those books,
Figure: 01 |
On one side,we have the clients , this is the web application, or mobile application,or doorbell or smart watch,or what ever interfaces use access to data.
On the other side we have the data store(the book racks), typically a database or database server or some other type server.
Figure :02 |
And there's in the librarian(Figure :02) sits our library the REST API , receiving , processing,and handling
responses.
When a client submits a request(Figure: 03),in this case to get a resource, the REST API
receives that request, identifies the requested resource, figures out what data needs to be gathered,and in what format, creates a representation of the data, matching the request format,bundles it all up with the response header containing meta-data, like the resource ID,and hyper-links to available actions,the media formats this response has when the response was sent and other information,and send it all back to client. The client receives the data and parses it into something meaningful on its end, while the REST API sits quietly waiting for the next request.
Figure: 03 |
Next, the client, or rather its user wants to change something(Figure: 04). this changes are applied to the content received in the original response,and sent back as a put request using the original ID. The REST API receives the request,recognizes this as a put request for an existing resource, notes the requested media format,identifies the requested resource, converts the requested data into a media format that works for the data store,makes the
changes submitted,and returns the new presentation of the resource along with a success message to notify the client everything went as expected.
Figure: 04 |
In this example we have one client sending requests to the REST API. In most applications we'll have several,maybe hundreds or thousands, or millions of clients making requests,so the librarian will be very busy. But the actual flow is exactly the same. The client makes the request,the REST API receives the request, gathers and parses the data, and return that data and the response header to the client.
I think that you have a rough idea about what REST API is? ;)
For more information Stay Tuned for my REST API (Part II) article.
Thank You!!
Sanduniisa.
Do you know what is Page Ranking? Visit:
GOOD job Sanduni...
ReplyDelete