REST stands for Representational State Transfer, a term coined by Roy Fielding in 2000. It is an architecture style for designing loosely coupled applications over HTTP, that is often used in the development of web services. REST does not enforce any rule regarding how it should be implemented at a lower level, it just put high-level design guidelines and leave you to think of your own implementation.
REST Architectural Constraints are design rules that are applied to establish the distinct characteristics of the REST architectural style.
If you follow all constraints designed by the REST architectural style your system is considered RESTful.
If you follow all constraints designed by the REST architectural style your system is considered RESTful.
REST Architectural Constraints
REST defines 6 architectural constraints that make any web service – a true RESTful API.
- Client-Server
- Stateless
- Cacheable
- Uniform Interface
- Layered System
- Code On Demand (Optional)
Client-Server
This constraint keeps the client and server loosely coupled. In this case, the client does not need to know the implementation details in the server, and the server is not worried about how the data is used by the client. However, a common interface is maintained between the client and server to ease communication. This constraint is based on the principle of Separation of concerns.
![]() |
Figure: Client-Server |
Applying separation of concerns:
- Separates user interface concerns from data storage concerns.
- Improves portability of interface across multiple platforms.
- Improves scalability by simplifying server components.
- Allows the components to evolve independently.
Stateless
There should be no need for the service to keep user sessions. In other words, the constraint says that the server should not remember the state of the application. As a consequence, the client should send all information necessary for execution along with each request, because the server cannot reuse information from previous requests as it didn’t memorize them. All info needed is in the message.
Figure: Stateless
By applying statelessness constraint:
- Session state is kept entirely on the client.
- Visibility is improved since a monitoring system does not have to look beyond a single request.
- Reliability is improved due to easier recoverability from partial failures.
- Scalability is improved due to not having to allocate resources for storing state
- The server does not have to manage resource usage across requests.
Cacheable
This constraint has to support a caching system. The network infrastructure should support a cache at different levels. Caching can avoid repeated round trips between the client and the server for retrieving the same resource.
![]() |
Figure: Cacheable |
By adding optional non-shared caching:
- Data within a response to a request is implicitly or explicitly labeled as cacheable or non-cacheable.
- If a response is cacheable, then a client cache is given the right to reuse that response data for later, equivalent requests.
- Improves efficiency, scalability, and user-perceived performance.
- Tradeoff: cacheable constraint reduces Reliability.
Uniform Interface
This constraint indicates a generic interface to manage all the interactions between the client and server in a unified way, which simplifies and decouples the architecture. This constraint indicates that each resource exposed for use by the client must have a unique address and should be accessible through a generic interface. The client can act on the resources by using a generic set of methods.
![]() |
Figure: Uniform Interface |
By applying uniform interface constraint:
The overall system architecture is simplified and the visibility of interactions is improved. Implementations are decoupled from the services they provide and encourage independent evolvability.
Trade-off: Degrades efficiency since information is transferred in a standardized form rather than one which is specific to the application's needs. Further, a uniform interface has four sub-constraints
Trade-off: Degrades efficiency since information is transferred in a standardized form rather than one which is specific to the application's needs. Further, a uniform interface has four sub-constraints
- Identification of resources
- Manipulation of resources through representations
- Self-descriptive messages
- Hypermedia as the engine of application state (HATEOAS)
Identification of resources
Each resource must have a specific and cohesive URI to be made available. REST APIs are designed around resources, which are any kind of object, data, or service that can be accessed by the client.
A resource has an identifier, which is a URI that uniquely identifies that resource.
For example, the URI for a particular customer order might be:
http://adventure-works.com/orders/1
Resource representation – This is how the resource will return to the client. This representation can be in HTML, XML, JSON, TXT, and more. Clients interact with a service by exchanging representations of resources. Many web APIs use JSON as the exchange format. For example, a GET request to the URI listed above might return this response body:
{"orderId":1,"orderValue":99.90,"productId":1,"quantity":1}
Self-descriptive Messages
Each message includes enough information to describe how to process the message. Beyond what we have seen so far, the passage of meta information is needed (metadata) in the request and response. Some of this information are: HTTP response code, Host, Content-Type etc. Taking as an example the same URI as we have just seen:
GET /#!/user/ramesh HTTP/1.1
User-Agent: Chrome/37.0.2062.94
Accept: application/json
Host: exampledomain.com
Hypermedia as the Engine of Application State (HATEOAS)
REST APIs are driven by hypermedia links that are contained in the representation. For example, the following shows a JSON representation of an order. It contains links to get or update the customer associated with the order.
Just one example:
{
"orderID":3,
"productID":2,
"quantity":4,
"orderValue":16.60,
"links": [
{"rel":"product","href":"http://adventure-works.com/customers/3", "action":"GET" },
{"rel":"product","href":"http://adventure-works.com/customers/3", "action":"PUT" }
]
}
Layered System
The server can have multiple layers for implementation. This layered architecture helps to improve scalability by enabling load balancing. It also improves the performance by providing shared caches at different levels.
![]() |
Figure: Layered System
|
- Similar to the client-server constraint this constraint improves simplicity by separating concerns.
- Can be used to encapsulate legacy services or protect new services from legacy clients.
- Intermediaries can be used to improve system scalability by enabling load balancing
- Placing shared caches at the boundaries of the organizational domain can result in significant benefits. Can also enforce security policies e.g. firewall.
- Intermediaries can actively transform message content since messages are self-descriptive and their semantics are visible to the intermediaries Tradeoff: Adds overhead and latency and reduce user-perceived performance.
Code on Demand
This constraint is optional. This constraint indicates that the functionality of the client applications can be extended at runtime by allowing a code download from the server and executing the code. Some examples are the applets and the JavaScript code that get transferred and executed at the client-side at runtime.
![]() |
Figure: Code on demand |
By applying Code on demand constraint:
- Simplifies clients, hence promote the reduced coupling of features.
- Improves scalability by virtue of the server off-loading work onto the clients.
- Trade-off: Reduces visibility generated by the code itself, which is hard for an intermediary to interpret.
Conclusion
In this post, we have seen the 6 important REST Architectural Constraints.
Now we understand that these 6 architectural constraints which make any web service – a truly RESTful API.
These constraints of the REST architectural style affect the following REST architectural properties.
Reference
Related Posts
Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours
Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course
Happy to chat on your blog, I feel like I can't wait to read more reliable posts and think we all want to thank many blog posts to share with us.
ReplyDeleteData Science in Bangalore
A good blog always contains new and exciting information and as I read it I felt that this blog really has all of these qualities that make a blog.
ReplyDeleteData Analytics Course in Patna
ReplyDeleteVery informative message! There is so much information here that can help any business start a successful social media campaign!Data Analytics Course in Kolkata
I couldn't leave your website until I told you that I really appreciated the high quality information it presents to your visitors. I will come back frequently to check for new posts.
ReplyDeleteData Scientist Course in Durgapur
It's like you've got the point right, but forgot to include your readers. Maybe you should think about it from different angles.
ReplyDeleteData Science Course in Gorakhpur
A good blog always contains new and exciting information and as I read it I felt that this blog really has all of these qualities that make a blog.
ReplyDeleteData Science Institutes in Bangalore
Very informative message! There is so much information here that can help me thank you for sharing
ReplyDeleteData Analytics Course in Chandigarh
Excellent effort to make this blog more wonderful and informative. The information shared was very useful.
ReplyDeleteData Analytics Course in Chandigarh
I'm always looking online for articles that can help me. I think you also made some good comments on the functions. Keep up the good work!
ReplyDeleteData Scientist Course in Bangalore
I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. Keep up the good work. Waiting for your next article
ReplyDeleteBusiness Analytics Course in Jabalpur
Very educating blog, got lot of information thank you.
ReplyDeleteData Scientist Course in Amritsar
Very useful message. This is my first time visiting here. I found a lot of interesting things on your blog, especially your discussion. It really is a great article. Keep on going.
ReplyDeleteData Analytics Course in Ernakulam
It's like you've got the point right, but forgot to include your readers. Maybe you should think about it from different angles.
ReplyDeleteData Scientist Course Syllabus
Very useful article to read and Information was helpful.I would like to thank you for the efforts you had made for writing this awesome article.
ReplyDeleteData Analytics Course
It's like you've got the point right, but forgot to include your readers. Maybe you should think about it from different angles.
ReplyDeleteBest Data Science Courses in Bangalore
Really impressed! Everything is a very open and very clear clarification of the issues. It contains true facts. Your website is very valuable. Thanks for sharing.
ReplyDeleteBest Data Analytics Courses in Bangalore
Very informative message! There is so much information here that can help any business start a successful social media campaign!
ReplyDeleteData Analytics Bangalore
It's like you've got the point right, but forgot to include your readers. Maybe you should think about it from different angles.
ReplyDeleteBusiness Analytics Course in Nashik
I was curious if you ever thought of changing the layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 pictures. Maybe you could space it out better?|data analytics course in jodhpur
ReplyDeleteHi, This article is probably where I got the most useful information for my research. Do you know of any other websites on this topic?
ReplyDeleteData Science Training in Ahmedabad
I read your excellent post. It's a great job. I enjoyed reading your post for the first time. I want to thank you for this publication. Thank you...
ReplyDeleteData Analytics Course in Patna
I have bookmarked your site since this site contains significant data in it. You rock for keeping incredible stuff. I am a lot of appreciative of this site.
ReplyDelete360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.
ReplyDeleteWonderful illustrated information. Thank you. It will certainly be very useful for my future projects. I would love to see more articles on the same topic!
ReplyDeleteData Science Training in Bangalore
It would also motivate almost everyone to save this webpage for their favorite helper to help get the look published.
ReplyDeleteData Science Training in Patna
Superb Information, I really appreciated with it, This is fine to read and valuable pro potential, I really bookmark it, pro broaden read. Appreciation pro sharing. I like it.Data Analytics Course in Dombivli
ReplyDeleteI wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts. business analytics course in surat
ReplyDeleteGood blog and absolutely exceptional. You can do a lot better, but I still say it's perfect. Keep doing your best.
ReplyDeleteData Science Training in Durgapur
It's like you've got the point right, but forgot to include your readers. Maybe you should think about it from different angles.
ReplyDeleteData Analytics Course in Erode
Very informative message! There is so much information here that can help any business start a successful social media campaign!
ReplyDeleteBusiness Analytics Course in Gorakhpur
I have read your article, it is very informative and useful to me, I admire the valuable information you offer in your articles. Thanks for posting it ...
ReplyDeleteBusiness Analytics Course in Ernakulam
Thanks for the informative and helpful post, obviously in your blog everything is good.
ReplyDeletedata science course
I read your excellent blog post. It's a great job. I enjoyed reading your post for the first time, thank you.
ReplyDeleteData Science Institutes in Bangalore
Very informative message! There is so much information here that can help any business start a successful social media campaign!
ReplyDeleteBusiness Analytics Course
I want to thank you for your efforts in writing this article. The information provided was very useful.
ReplyDeleteData Science Certification Bangalore
Very informative message! There is so much information here that can help any business start a successful social media campaign!
ReplyDeleteData Scientist Course Syllabus
I am always searching online for articles that can help me and you made some good points in Features also. Keep working, great job
ReplyDeleteData Science Training
I truly appreciate just perusing the entirety of your weblogs. Just needed to educate you that you have individuals like me who value your work. Unquestionably an extraordinary post. Caps off to you! The data that you have given is exceptionally useful.data scientist course in bhopal
ReplyDeleteNice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
ReplyDeletedata scientist course in malaysia
Well done for this excellent article. and really enjoyed reading this article today it might be one of the best articles I have read so far and please keep this work of the same quality.
ReplyDeleteData Analytics Course in Noida
Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well.Data Science Course in Dombivli
ReplyDeleteI am sure it will help many people. Keep up the good work. It's very compelling and I enjoyed browsing the entire blog.
ReplyDeleteBusiness Analytics Course in Bangalore
Nice Post i have read this article and if I can I would like to suggest some cool tips or advice and perhaps you could write future articles that reference this article. I want to know more!
ReplyDeleteData Analytics Course in Gurgaon
I was surfing the net and luckily I came across this site and found some very interesting things here. It's a lot of fun to read. I really enjoyed it. Thank you for sharing this wonderful information.
ReplyDeleteBusiness Analytics Course in Durgapur
I always search online for articles that can help me. Obviously, there is a lot to know about this. I think you made a few good points about the features as well. Keep up the good work!
ReplyDeleteData Scientist Course in Ernakulam
360DigiTMG delivers the best Data Analytics course with placements. Top industry trainers, LMS access, world-class curriculum, mock interviews, and guidance sessions for resume preparation.Data Analytics Course in Faridabad
ReplyDelete360DigiTMG offers the best Data Analytics courses in the market with placement assistance and live projects. Enroll today and become a Data Science professional in the next 6 months.Data Analytics Course in Chandigarh
ReplyDeleteAre you looking for a Data Science course that will introduce you to all the fundamental concepts with a practical approach. 360DigiTMG is the right place for you. for more details click the link below.business analytics course in Durgapur
ReplyDeleteAre you looking for a Data Science course that will introduce you to all the fundamental concepts with a practical approach. 360DigiTMG is the right place for you. for more details click the link below.business analytics course in Trichy
ReplyDeleteDon't let pandemic affect your career growth, become a successful Data Scientist with the best course offered online at 360DigiTMG.business analytics course in rourkela
ReplyDeleteAre you searching for the best Data Science certification online with placement assistance then 360DigiTMG is the best institute for you. Enroll today!data analytics course in meerut
ReplyDeleteAre you looking for a Data Science training institute that will not only train you but also aid you in bagging a job, 360DigiTMG is the right place for you.
ReplyDeletebusiness analytics course in trichy
Without data analytics, you cannot imagine data science. In this process, data is examined to transform it into a meaningful aspect.
ReplyDeletedata science course in patna
Embark on a journey to achieve your professional goals by enrolling in the Data Scientist course in Bangalore. Learn the skills of collecting, extracting, analyzing, preparing, visualizing, and presenting results to make valuable decisions. Master the concepts of data science through hands-on projects and case studies to learn the latest trends and skills in this field.
ReplyDeleteBest Data Science Institute in Bangalore
When one thinks about data science, there might be word machine learning comes into the mind.data science course in nashik
ReplyDeleteRegister for the Data Science certification in Bangalore and gain recognition and credibility in your organization. Learn the techniques to examine large data sets and discover patterns that are valuable to predict market trends. Learn Data Exploration and Visualizations, Neural Networks and Deep Learning, Model Evaluation and Analysis. This course will ensure that you are challenged to go from a beginner with no Data Science experience to someone who can juggle data with ease.
ReplyDeleteData Science Training and Placement in Bangalore
Gain expertise in the relevant and current practices, challenges, and research involved in the field of Data Science. Learn all the skills from non-coding essentials to data science and machine learning by enrolling in the Data Science course in Bangalore. Using real data sets across a range of domains enhances your skills in supervised and unsupervised learning, neural networks, sampling techniques, support vector machines, and more. Get certified in Data Science to get one step ahead towards a lucrative career.
ReplyDeleteData Science Course in Bangalore with Placement