"We are all now connected by the Internet, like neurons in a giant brain."
The foundation on which our internet is made out of is fairly complicated. In my attempts to teach my friends/family about how it works, I'm going to attempt to make as many blog posts as I can attempting to simplify CS terms and concepts. Today I'll be explaining (very broadly; well. kinda broadly) what HTTP and RESTful APIs are.
The first thing you gotta know is that these seem complicated because of the million acronyms we have in the computer science world. After we break those down, things are fairly simple. First we have...
HTTP (HyperText Transfer Protocol)
Most people know as http as "those characters in front of all the links." But they don't know what it is. HTTP is a protocol, so it's really just the agreed upon format where two entities (server/computer/machines/clients/whatever) talk to each other over the internet.
This communication happens in a request-response format. Entity1 REQUESTS something and depending on the URL location/authorization/security/permissions/etc, Entity2 RESPONDS with a message called a header, and maybe even with the data that Entity1 requested.
Computers are dumb. They don't have any concept or knowledge of what a "noun" is. To computers, a "noun" is something we call a "resource". How we locate these resources are through a URL (Uniform Resource Locator). Resources can be something as simple as a picture, some text, a script, or even full-fledged websites.
REST (Representational State Transfer)
If resources are "nouns", then a structure called REST or a RESTful web service are the "verbs". REST is basically how we can interact with the resources, the methods in which the nouns interact other entities.
There are four methods in REST (these are the 'requests' in the request-response method, mentioned above) :
- GET: a request to retrieve a resource
- POST: a request to give a resource
- PUT: a request to update a resource
- DELETE: a request to delete a resource
After you make a request for something, the server responds with a header and a message. Inside the header, there is usually a status code. What the status code begins with is usually an indicator of how your request went.
- 1xx: hold on
- 2xx: here you go
- 3xx: go away
- 4xx: you screwed up
- 5xx: i screwed up
Common ones are 200 which is success. And 404 which means not found.
Putting it all together
So as I said in the beginning, HTTP is a agreed upon protocol in which the internet functions. They use RESTful web services/APIs (verbs) to pass resources (nouns) and to interact with other entities over the internet.
So when you type "http://google.com" into your web browser, all your browser is really doing is sending a GET request to 'google.com' and it responds by sending you all the files that are associated with it. (Images, text, HTML, etc)
Whenever you submit a form on the internet (like signing up for something), its typically a POST request. You're just sending them some information over the internet and depending on what happens, they add it to the databases.
Well that's a very basic outline of what HTTP and REST is. Hope this helped your basic understanding or maybe peak your interest on the topic.