The topic for this blog post was REST API. I chose this topic because later on in the semester we will be going over REST API design and I wanted to get a firm understanding of what REST APIs are first. I watched the video linked below, which is titled “REST API Crash Course”, in which the first half of the video was defining and explaining what a REST API is and then the second half was how to implement REST APIs in your code. https://www.youtube.com/watch?v=qbLc5a9jdXo
To begin, what exactly is a “REST API.” It stands for Representational State Transfer Application Programming Interface. The REST part is a set of rules and guidelines about how you should build a web API. The API part is another set of rules and guidelines about how applications communicate with one another.
In essence REST APIs are a way for two softwares to communicate with one another. No two softwares are built the same and have their own factors and variables. For instance, if you have one application coded in Python and another application coded in JavaScript and wanted them to communicate to one another… they would not be able to due to the fact they are in different languages. This is where REST APIs come in which enables a pathway for communication between the two different applications.
We can further expand on this by using client-server communication example. The server exposes an endpoint API → client makes a request to the endpoint API of the server→ the server processes the request → once processed, the server sends it back to the client in a JSON format.
It should be noted the client should NOT go directly to a database. If a client to database connection did occur, it would not be good due to the fact the database info would be exposed; which could lead to corruption and information getting exposed inside of the database. With an API, the client does not receive database credentials, limited with permissions to the extent of the API, and the server always retains the real database credentials. Long story short, with an API the information stays hidden.
There are four main methods of requesting data from the server:
-GET is used to retrieve information from the server.
-POST is used to write information to the server; add a resource.
-PUT is used to update/replace a resource on the server.
-DELETE is used to remove a resource from the server.
Learning about REST APIs and APIs in general makes me feel a lot more comfortable when we do get to the point of our semester of REST API design. Furthermore, it’s all starting to come together in terms of software construction. Starting with design then going to a better structured scalable design, addressing the relationships of servers and clients in class and soon REST API design, very cool, looking forward to it!
From the blog CS@Worcester – Programming with Santiago by Santiago Donadio and used with permission of the author. All other rights reserved by the author.
