Chapter 3: REST API

REST APIs

face Josiah Wang

There is a special group of Web APIs known as REST.

In case you are wondering what REST means (don’t we all need a rest now?), it stands for REpresentational State Transfer.

REST is a software architectural style for Web services that follows certain principles. It defines how protocols like HTTP should be used.

Any Web API that follows these guiding principles are called RESTful API.

We won’t discuss REST in much detail. It is enough to know that RESTful APIs are subject to some constraints (there is no need to understand all of them):

  • Client-server architecture: Clients and servers are separate
  • Statelessness
    • Each request should be independent of previous requests
    • So each request must contain all of the information necessary to understand the request
  • Cacheability: Resources should allow caching unless explicitly indicated otherwise
  • Layered system
  • Uniform interface

APIs that do not strictly conform to these constraints are known as REST-like APIs.

REST API responses tend to be in JSON (most common), text or XML, but they can be anything really! This allows both the servers and clients to be written in whatever programming language the authors prefer. And I assume you all love Python the most! 😊