I’m a REST API developer and I have experience working on developing web services using REST API. Based on my experience, I’m listing RESTful web services interview questions.
If you are applying for Web Service or API development, or if you have mentioned REST API as a skill in your resume, be prepared to answer the following questions.
Table of Contents
It takes just a few minutes. Don’t miss it.
REST is the Representation State Transfer, an architectural style or new standard defined for developing web services or APIs.
Web services that use the REST APIs and provide the REST interface for accessing the resource are called RESTful web services.
REST APIs are very popular and in-demand.
My statement is not baseless. Check this Google trend for “REST API”.
There are many reasons behind the Growth of REST API or RESTful web service.
Every resource in REST has a unique Uniform Resource Identifier (URI). URI is used to identify each resource. These resources are described in the form of formatting languages like JSON, XML…
Every resource has different properties. These properties are defined in JSON or XML format.
Here is the standard URI format.
This format can vary depending on the grouping and hierarchical structure of each resource.
We can use different HTTP methods like HEAD, GET, PUT, POST, or DELETE based on the operation we want to perform on resources. (Each of these HTTP methods is defined in the latter part of this article.)
If you are accessing REST APIs from the remote client, you need to provide the IP address.
Here are the characteristics of RESTful web services or REST APIs.
Read each REST API characteristic in more detail.
Answer: There are many protocols and architecture defined for client-server communication in web services. The two major types of web services are SOAP (Simple Object Access Protocol) protocol and REST architecture.
Even if you are attending an interview for RESTful web services, it is expected you know the SOAP protocol, at least some basics.
Answer: To answer this question, you should mention a couple of points. Even if you are working in REST APIs, you should know the fundamentals of SOAP and how it is different from REST APIs.
For more detail about each point, read the difference between SOAP and REST API where I have explained all these differences. Remember some of them.
There are two characteristic differences between these two protocols that decide which one to use in any web application services.
SOAP is more useful when you want to develop more secure applications like banking operations.
REST API can be used to develop any public or multimedia web services where we don’t concern much about operational security.
We can use the HTTP method to access the REST web services from the client. There are multiple tools we can use to call REST APIs.
Here are the HTTP methods used to access the resource in RESTful web services.
|Sr. NO.||HTTP Method||Use|
|1||GET||It is used to access resources and to know the state of a particular resource.|
|2||HEAD||This method requests the header which is required for client-server communication.|
|3||POST||It performs operations on a resource like creating and updating resource properties.|
|4||PUT||It is similar to the POST method. The only difference is, PUT follows the idempotent rule and POST does not.|
|5||DELETE||This method removes the resource.|
|6||OPTIONS||It describes the communication options for the target resource.|
Both the POST and PUT methods are used in HTML to create or update the resource properties.
The basic difference between two is, PUT follows the idempotent rule, whereas POST does not follow this rule.
What is the idempotent rule?
Suppose if you retry the POST method n-times to create a resource, n-resources will be created.
Now in the case of the PUT method, if you execute the PUT method the first time, it just creates one resource. It caches the output. Next time when you execute the same operation, instead of creating a new resource, it returns the output from the cache.
As the PUT method uses a cache mechanism to return the output for an identical request, it is faster than the POST method.
The following HTTP methods obey the idempotent rule.
Below HTTP methods do not support idempotent rule.
Yes, REST APIs are stateless. It does not preserve the session or the state of the client on the REST server. It does not save any client data, session, or information for any request. Every request whether it’s from the same client or from a different client executes independently.
RESTful web services could be restart between two API calls or requests without impacting response.
There is new counter technology in API development called GraphQL. If the interviewer is aware of GraphQL, they can ask you about it. Learn the difference between REST API and GraphQL.
These are the RESTful Web Services Interview Questions as per my experience while attending interviews with product-based companies. I hope you find this guide useful for your interview preparation.
All the Best!