What is REST?
REST is a set of conventions for creating APIs which operate over
HTTP. To put it in simpler terms, REST offers some guidelines on how
an application and server should interact over the web.
What does REST stand for?
Good question. REST stands for REpresentational State Transfer. An
API is said to be RESTful, if it follows the REST guidelines.
What does the name even mean?
I found the best explanation to this question over here.
It boils down to this. A client requests a resource from a server
(eg. CPU temperature of the server). The server then responds by
sending back a representation of the resource that can be understood
by the client. In the case of REST, the response should be textual in
nature. In the above example (CPU temp), the server simply responds
with a temperature value (eg. 50C). If the client requests an image,
the server will respond with a URL (still text :D) leading to the
image. Now, when a client recieves a representation from the server,
the state of the client changes. That is, if a client requests for an
image and receives the repsresentation (URL) leading to the image, it
puts the client in a new state. It doesn't matter what the client
does with the image, what matters is the fact that the client has a
representation (URL) of the resource (image). Likewise, the client's
state will keep on changing (transfering) for each subsequent request
and response. Thus the name.
An example, please?
Let's say we have an application, which monitors the health of a server.
In this scenario, the application would be the client and the server
would be, well, the server. Let's assume the server is available through
the IP "192.168.1.2". To get the uptime of the host, the client could
retrieve the URL "http://192.168.1.2/uptime" (this by the way is an
HTTP GET method). The server could then respond with something like
this (usually using HTTP POST method).
{
"uptime_sec": 1223463
}
The response here is in JSON but it can be in any format as long as it is textual (eg. YAML). Once the client receives the data, it does what it is programmed to do (eg. presenting the information in a human friendly way). Also note that the client can use any valid HTTP method (including POST) for communicating with the server.
How to get started with REST?
Far wiser people have written countless articles on getting started
with REST. You can google them. But for Python, this
article is by far the best I have seen. Before you begin, make sure to check
out the Wikipedia
page on REST and pay attention to Architectural constraints. The REST Cookbook
can help you iron out some of the niggles people face when building
a REST API.