22 Jul: A REST is Good for You

Respresentatonal State Transfer (REST) is way of providing interoperability between two network connected systems. In a minimal (and somewhat over-simplified) statement:
"A REST API defines a set of functions which developers can perform requests and receive responses via HTTP protocol such as GET and POST."
Properties of REST:
  1. Client-server - the client and server are seperate and independant
  2. Stateless - each request is complete, no session state is maintained by the server
  3. Uniform Interface - request use: POST (create), GET (read), PUT (edit) and DELETE. Objects are manipulated using URIs which are their sole identifiers
  4. Cachable - responses must indicate whether they can be cached, and clients must cache if possible for scalability
  5. Layered - an architecture of hierachical layers where each component only needs to understand the layed it interacts with
  6. Code-on-demand (optional) - servers can temporarily extend client function by transfering executable code
Example of using a REST API:
where the variables project, zone and disk define the object you want to get the properties of. Or for an API that doesn't need authentication:
$ curl -s | json_pp | grep statusSeverityDescription
            "statusSeverityDescription" : "Good Service",
Here the variable is "jubilee" (the name of one of the London Underground lines), and this call is to check the status for any disruption, so it will just read information therefore its a GET request. The documentation covers the details how to interact with the API:!/Line/Line_StatusById.
© 2017