You can read the original/updated article on Code Maze blog.

Many giants like Facebook, Google, GitHub, Netflix, Amazon, and Twitter have their own REST(ful) APIs that you can access to get or even write data.

By why all the need for REST?

Is it that good and why is it so prevalent?

Surely it’s not the only way to convey messages?

What is the difference between REST and HTTP?

Well, it turns out REST is pretty flexible and compatible with HTTP (which is the main protocol the internet is based upon). Since it is an architectural style and not the standard, it provides a lot of freedom to implement various design best practices. Did I mention it’s language agnostic?

In this blog post, my goal will be to explain REST as clearly as possible so you can clearly understand when and how to use it, as well as what it is in essence.

We’ll go through some basics and definitions as well as show off some REST API best practices. This should give you all the knowledge you need to implement REST APIs in any language in which you prefer to code.

If you are not that familiar with HTTP, I recommend reading our HTTP series, or at least part 1 of it, so you can digest this material more easily.

So What Is REST Essentially?

REST (Representational State Transfer) is an architectural style founded by Roy Fielding in his Ph.D. dissertation “Architectural Styles and the Design of Network-based Software Architectures” at UC Irvine. He developed it in parallel with HTTP 1.1 (no pressure).

We use REST primarily as a way to communicate between computer systems on the World Wide Web.

Is REST Bound to HTTP?

By definition, it’s not. Although you can use some other application protocol with REST, HTTP has remained the undisputed champion among application protocols when it comes to the implementation of REST.

What Does RESTful API Mean?

“RESTful” implies a few features:

  • Client-server architecture: The complete service is comprised of the “Client” which is the front-end and the “Server” which is the backend part of the whole system.
  • Stateless: The server should not save any states between different requests. The state of the session is exclusively left to the responsibility of the client. As per the definition of REST: All REST interactions are stateless. That is, each request contains all of the information necessary for a connector to understand the request, independent of any requests that may have preceded it. (Roy’s dissertation ch. 5.2.2)
  • Cacheable: The client should be able to store responses in a cache for greater performance.

So, the RESTful API is a service that follows these rules (hopefully) and uses HTTP methods to manipulate the set of resources.

But why do we need or use RESTful APIs?

Because they give us an easy, flexible, and scalable way to make distributed applications that communicate over the internet.

#integration #rest api #error handling #rest api documentation #api

Top REST API Best Practices
1.90 GEEK