Summary of the best practices of REST API with a huge mind map.
"REST API Design Rulebook" is a book by Mark Masse that provides guidelines for designing REST APIs. Here I used it as a reference to define my rule set and the best practices.
Introduction
As a developer, you may find yourself needing to build or consume a REST API at some point in your career. REST APIs are a popular way for systems to communicate with each other over the web, and they offer many benefits such as being easy to use and maintain. However, it's important to follow best practices when designing and building a REST API to ensure it is reliable, scalable, and easy to use for clients.
Unfortunately, not all developers follow best practices when building an API. This can lead to issues such as confusing or inconsistent URL conventions, which can make the API more difficult to use and understand. In this blog post, we'll cover the most important best practices for designing and building a REST API from a developer's perspective. Here I introduced a set of rules to remember well. As well I designed a huge mind map to store the rules in your brain. By following these best practices, you can build an API that is easy to use and understand, and avoid common pitfalls that can lead to frustration for API users.
"REST API Design Rulebook" is a book by Mark Masse that provides guidelines for designing REST APIs. Here I used it as a reference to define my rule set and the best practices.
REST API Mindmap sharable image
1. What is REST API
Here we are discussing, "What is REST?", main constraints, and benefits. Furthermore here shows how to communicate with clients and servers through HTTP. I am hoping to deep dive into this soon in another blog post.
2. URI Definition
A URI (Uniform Resource Identifier) is a string of characters that identifies a resource on the web. In the context of a REST API, it is common to use URLs to identify resources, as they specify both the name and location of the resource.
In this section, I put some best practices for using URI. We can discuss this in a more informative way in the near future.
3. URI Authority Design
In a URI, the authority is the part of the URI that specifies the location of the resource. According to the PDF, there are 4 archetypes for modeling resources in URI. We will discuss this topic in the future more descriptively. Keep in touch with my blog.
4. URI Path Design
The path portion of a URI is the part of the URI that follows the authority and specifies the name and location of the resource being accessed. It is important to follow best practices when designing the path of a URI to ensure it is easy to use and understand.
This is the most critical section for a backend developer who designs well REST API. I plan to write a blog post on this section soon.
5. URI Query Design
The query portion of a URI is the part of the URI that follows the path and specifies additional information about the resource being accessed. The query is typically made up of one or more key-value pairs separated by an ampersand (&).
Here are some best practices for designing the query portion of a URI. I put them much as, possible into this section. Go through the mind map and follow these practices in your code base.
6. HTTP Methods
In the context of a REST API, HTTP methods (also known as "verbs") are used to specify the desired action to be performed on a resource. This section is the most important one for the developer's life. Keep in touch with descriptive blog posts on this in the future.
7. Response Codes
In a REST API, HTTP response codes are used to indicate the status of a request. They provide information about whether the request was successful or encountered an error and provide additional information about the nature of the error.
Here I put most high-level error patterns and usage. We can discuss the most important response codes and other codes in the next couple of blogs.
8. Versioning
9. Client Concerns
10. Documentation
Documentation is an important part of any REST API. It provides information about the API's functionality, resources, and available operations, as well as any requirements or restrictions. We will discuss more tools and techniques near future.
11. HATEOS
12. Resources
"REST API Design Rulebook" is a book by Mark Masse that provides guidelines for designing REST APIs. Here I used it as the main reference to improve my best practices on REST API.
I hope this information has been helpful! Let me know if you have any further questions. I will plan to discuss the above topics from a REST API blog series. Keep in touch on my blog site. Happy Coding!!
Learn something new. Comment your thoughts and share the content.
Happy coding!!
See you again soon. ✌✌