RESTful
2 minutes of reading
APIs that we refer to as RESTful meet certain criteria, such as using HTTP as the primary means of communication and having structure and resources that can be referenced via URLs.
RESTful means that the API in question is fully compatible with the REST standard. The REST software development standard refers in particular to websites. In order to claim that the API we wrote meets the REST standards, it must meet the following requirements in practice:
- Unique methods by which it queries the API such as GET, PUT, DELETE, PATCH defined as a unified interface.
- The given query is independent of the state of the application, it always returns the same thing, i.e. if we ask for a resource with ID=1 in the API then regardless of whether we are user A or B we should get the same thing
- The API returns messages about whether the query was successful or returned an error. The API should indicate exactly what the error was.
- The query to the API should explicitly state what type of resource it is querying, and for book querying we will use a different one
- The client does not directly interact with the server's resources in any way
- Ability to use cache. The API must return information whether the resource is stored and whether it can be stored
It is worth remembering that REST is not the same as HTTP, and also REST does not impose in any way the type of data that is returned from the API. It can be either JSON or plain text.
What a REST query to the API looks like
Each API query should have the following elements:
- Endpoint name
- Type of method
- Headers
- Data
An example query of type GET would be
curl -H "Authorization: OAuth <ACCESS_TOKEN>" http://www.example.com/users/2
Practical RESTful tips
There are a lot of generalities about RESTful APIs, but it's hard to find good resources on what to do to actually make our APIs meet REST standards.
URL construction in a RESTful API
One of the most important things is the construction of the URL. The url should have:
- use only lowercase letters
- use a hyphen ( - ) instead of an underline ( _ )
- do not add the return data type to our url, instead you should use Content-Type in the header
- use plural in the name for collection names, e.g. /books/
- use singular for document names, e.g. /books/sciencefiction/
- do not use create, delete methods in the name e.g. it is a mistake to make /deletebook/
- we can version and should add the main api version to the name e.g. /v1/books/
Returned response codes
The API should return response codes. The standard is responses containing error codes numbered from 2xx, 3xx, 4xx, 5xx. All but responses in the 200 group mean that there is an error in our API.
Related articles
Why Tailwind UI is a Must-Know for Modern Web Developers?
26 Oct 2023
In the realm of modern web development, the need for efficient tools is increasingly exigent. Harnessing the power of such an asset, Tailwind UI is emerging as a comprehensive solution. Streamlining the development process, it allows to make compelling web interfaces with ease. This write-up aims to explore the quintessence of Tailwind UI in today's digital age.

Understanding SOAP: Key Concepts and Practical Applications
16 Aug 2023
Understanding SOAP (Simple Object Access Protocol) can often prove daunting. This article seeks to demystify SOAP, exploring its core principles and its practical applications. By dissecting its structure and peeling back its layers, we can unravel its true potential and learn how to harness its capabilities in an efficient manner.
Influence of Google Fonts on UX and UI Design
3 Aug 2023
In the fusion of UX and UI design, nothing is trivial. Each element, including typography, plays a pivotal role in engaging user interaction. This article focuses on understanding the crucial influence of Google Fonts on UX & UI design. We delve into its impact on aesthetics, functionality, and overall user experience.
Human-Centered Design: Pivotal Player in the Arena of Modern Technology Development
17 Jul 2023
Human-Centered Design, a novel paradigm in modern technology development, is ensuring a revolution in software designs by prioritizing the user experience. As a core approach to problem-solving, it carefully blends technology with human needs to deliver highly-effective and usable solutions.
Unleashing the Power: A Comprehensive Guide to Mastering Affiliate Marketing
17 Jul 2023
This guide will embark you on a journey through the realm of Affiliate Marketing, illuminating its potency and progressive ways to harness it. Step into the universe where partnerships flourish, revenues stream, and brands expand, using dynamic marketing strategies.
Mastering the Art: Effective Strategies for Lead Nurturing in Tech Industries
17 Jul 2023
Lead nurturing in the tech industry is akin to conducting a symphony, where every note must be played in perfect harmony. It requires patience, precision, and a keen sense of timing. This article gears towards deciphering strategies that can help tech businesses skilfully navigate this intricate realm, fostering stronger customer connections and maximizing lead conversion.
Unleashing the Potential of CKEditor for Seamless Content Creation
5 Jul 2023
In this article, we will explore how to unleash the full potential of CKEditor for seamless content creation. CKEditor is a powerful and versatile text editor that offers a wide range of features and customization options. By understanding its capabilities and implementing best practices, we can optimize content creation processes and enhance the overall user experience. Let's dive in and discover the possibilities that CKEditor brings to the table!
Show all articles