What is an API ? or What is Rest API ? or What is Web Services?
Hi Folks! like me in your software development days, you may also have came across requirements like when someone has asked you
“Hey dude! share the API and the parameters for the form you have developed” OR “Create a RESTfull API for this”.
Me like “What the heck is that? I can write code and functions but how to create an API? “
A newbie like me had always found it hard to reply to such a question in the professional world.
Let’s deep dive to understand what it means.
What is an API ?
Definition: An API, or Application Programming Interface, is a set of definitions and protocols that allow one application to communicate with another application. (Phew !!! didn’t get the feel? Yeah, Me neither.
Newbie definition: an API allows two software programs to communicate with each other. One program can call another program’s API to get access to data or functionality of the other program. (Hmmm! , a little better but still not clear)
Let’s take an example : You went for dinning in any 5 star hotel.This is how it goes.
1.) A waiter will attend you , take your order , will write it down on paper in some fashion like “table no: dish name: quantity”.
2.) Waiter will pass that paper note to kitchen staff from a fixed window.
3.) Food on a tray (let’s assume) will be served with a note mentioning “table no: dish name : quantity: prepared by chef name”.
Now here, one program is YOU and another application is the person in Kitchen. The waiter is acting as an API taking order ( or request) writing in some (agreed) formate and passing to kitchen staff to understand and in return, they are serving data as food along with some other acknowledgment or data.
Now the question is how to create an API?
In general, when we speak about APIs, we are likely speaking about web APIs [APIs that are accessible over the internet]. This is not always the case though. APIs can be exposed through local files (such as a JAR file in a Java program, .H file in C/C++ programs, etc.) to allow two local applications to communicate with each other. This doesn’t require a network as the two applications are communicating within a single device.
So, when anyone asks to create an API, in general, it means,a DNS with path, (using HTTP protocol web application like PHP , java, c++ , python), hitting which (through the browser or curl request) can serve data or take data & perform some action.
so one needs create
1.) DNS with path (eg : https://bitsofjarvis/blogcount)
2.) API method : POST or GET or PUT or DELETE
3.) API response : like json , key-value
HHHH I really like your idea of teaching.