A few days ago I attended Postman's API 101 Workshop. This is an industry talk that the folks at Postman deliver at universities as part of their Student Program. And here's all that I learned:
First of all, Postman itself is not an API, as some of my classmates mistook it as, instead Postman is an application that is used to build APIs.
API stands for Application Programming Interface. That may not make much sense so let's leave it aside for now. We'll get back to that later.
The Modern-day Application
For now, let's look at a typical modern day web application. There are broadly two sides to it. The first is the thing we, as users, see. The webpages, the graphical interface with all the pretty buttons and illustrations, and all the fancy animations. This is called the front-end of your website. This is where you would provide any inputs and be able to view the output.
Now, the existence of this front-end implies that there must also exist a back-end. And it does!
The back-end of any app is the actual logic and the code that makes it behave like it's supposed to. All the heavy lifting behind the scenes that you, as a user of that app, might not see is happening here. Hence, the term back-end. This is where the inputs from the front-end are processed and an output is sent back to be displayed.
It's like going to a restaurant!
The expert at the workshop explains this with a brilliant analogy of a restaurant. When you go to a restaurant, the menu or the tables or the beautiful decor of the place is the front-end. But all the real work - cooking of the food - happens in the kitchen that you may not see. Hence, the kitchen is the back-end.
To APIs...
So far so good. Now naturally there must also exist a way through which these two sides communicate. Because how else would the front-end take your inputs to the back-end for processing, or bring back the output so you can see it?
At a restaurant, you yourself don't go to the kitchen and bring your order back from the chefs, right? That's what waiters are for! And that's exactly what APIs do too!
Waiters take your order details and relay it to the kitchen so the chefs can cook it up. And when they're done, waiters bring back the delicious cooked food back to your table as requested by you. Much like how APIs collect your inputs from the front-end via a request and relay it to the back-end where the inputs get processed and certain output is returned back to you as a response!
Enough about restaurants, how does it work in real life?
These requests and responses usually take place over HTTP in a real-world application. The front-end makes an HTTP request with the inputs in its request body at a certain API endpoint and is returned an output in a form of an HTTP response with a certain response body.
There are different kinds of HTTP requests that mean different things:
- The GET HTTP request method means that you want to receive some data.
- The POST HTTP method means that you also want to send some data.
- The PUT method means you want to update certain data.
- The DELETE method means you want to delete certain data.
These four kinds of requests come together to make a CRUD based API. This kind of API architecture is commonly called a REST API and the API is said to be RESTful.
OK, but why API?
There are literally thousands of APIs out there. A big advantage of using them is that you don't necessarily need to know the back-end logic yourself. As long as you know what data to input and what to expect in the output, you can totally use an API to do all the processing for you.
Since these API provide almost like an interface over some abstract logic code, they are said to be a layer of abstraction. And the different endpoints provide an interface to interact with the real code. All the developer needs to know is how to interact with this interface.
Hence the full form, i.e., Application Programming Interface. As they are nothing but an interface that can help you program your application by taking care of all the third-party logic.
So that's about it. The instructor of the workshop made us do all of this hands-on using Postman on a dummy jokes API. And you can interact with it too here: http://postman-student.herokuapp.com/joke/
Top comments (0)