Web API: Guide to Dr. Fielding’s RESTful API constraints

API constraints Web API

API constraints: We come across many APIs every day. If you think you are not in this category, then we have a question for you. Do you use Facebook, Twitter, or Github? If your answer is yes, then you are using APIs for sure. This is not the end of the list, as it just goes further. APIs are literally everywhere on the Internet.

Having a website requires building an API for it. You will either need it to provide to your mobile application, or to your website in an easily understood format. Developers should understand your API, as they can generate great things out of it. Understandable API is very important for the developer experience, but also to the user experience.

Web API design

Yet, do you know what the web API design is? People like fancy terms, so API became a popular nickname for a process of exchanging data between programs, websites, or services, which can be simply interpreted by a machine. Websites need easily formatted data so humans can understand them. We use HTML and CSS for the needs of a website, while we use JSON or XML for APIs.

Dr. Fielding’s constraints

More and more companies these days claim they are using a RESTful API design approach. REST defines API design rules that make an API easy to understand and work with. However, many of them still don’t meet the criteria and the requirements of the RESTful design. It would be nice if you have some time to check out Dr. Fielding’s doctoral thesis about RESTful design constraints. Dr.Fielding presents 6 RESTful API constraints. Half of them are widely known, while the half is a bit infamous. However, we will reveal both the famous and infamous RESTful design constraints.

Implementation of a uniform interface

Dr. Fielding claims that the easiest way to ensure the client and the server’s clear separation is to implement a uniform interface. It further provides easy application’s evolution. A uniform interface is a guarantee of a good client-server communication in one language, which is independent of the backend architecture. This server-client reliable communication goes through URI and HTTPS resources. All this is provided with the help of the uniform interface.

Layer hierarchy

Multiple layers system might be complicated, as every layer is liable for its own particular functions and a set of rules.

There has to be a controller that will control the actions and the outputs. Each layer definitely has a degree of independence, but it has to maintain a stable communication with the other layers. We can apply the same principle to RESTful API design, as it needs a similar architecture and hierarchy that will make everything scalable.

The layered system moves rarely used functions to another library, while protects the most common design parts. One more benefit of this system is the ability to move systems in and out of the architecture, knowing that it might contribute to the evolution and overall flexibility. However, this is only possible if the modules are loose.

Probably the best thing about the layered system is that it has the power to block attacks and prevent hackers from getting into the server’s architecture. It holds a strict firewall that further holds up insecure interactions between the client and the ingenious server.

Code on demand

This Dr. Fielding’s constraint is probably the least know, as it is optional. A code on demand allows easy transmission of the code and/or its applets with the help of the application’s API. This is the optional part – you can create an application that is independent of a code structure if you want to, but you don’t have to. This constraint wasn’t so well received among the developers of Dr. Fielding’s time. Yet, developers use this constraint broadly almost two decades later.

Conclusion

We discussed three of six Dr. Fielding’s constraints. The API constraints subjoin in REST – Representational State Transfer. Associated with one another, constraints build on complex and powerful programming interface.

Leave a Reply