13 RESTful Web Services Interview Questions & Answers | REST API
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.
RESTful Web Services Interview Questions
It takes just a few minutes. Don’t miss it.
1. What are REST and RESTful Web Services?
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.
2. Why REST APIs are getting more popular and in demand?
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.
- It uses standard HTTP protocol to access web services. So it is very easy for any user to access.
- RESTful web services can be access through the browser.
- As it uses HTTP protocol, the client does not require any extra setup.
- To use the REST API, the client does not require a complete understanding of all the APIs. It is easy to explore and finding properties of each API gradually.
3. What are the characteristics of REST API?
- It uses HTTP protocol to define the action like reading, writing or updating the resource.
- There can be multiple resources in web service. Each resource has a URI (Uniform Resource Identifier).
- JSON or XML formatting language is used to represent and to describe the resource.
- The resource is accessed using URI over the HTTP GET method.
4. How the Resources are Represented in REST?
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.
5. Explain the URI Format with Example.
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.
6. What are the characteristics of REST APIs?
Here are the characteristics of RESTful web services or REST APIs.
- Client-Server Architectures
- Layered Systems
- Uniform Interfaces
- Self-descriptive Messages
- Hypermedia as the Engine of Application State (HATEOAS)
Read each REST API characteristic in more detail.
7. What are the Different Types of Web Services?
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.
8. What is the difference between SOAP and REST APIs?
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.
- REST API services and clients are loosely coupled as compare to SOAP services.
- Using REST, we can access the resource by URI through the internet browser.
- To use SOAP services, the client should know every detail about the API.
- Users can start using the REST API with zero knowledge if they know the root URI. Users can explore the resource using the Hypermedia engine.
- SOAP is not a stateless protocol. SOAP services preserve the session and state of the client.
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.
9. When to Use SOAP/REST API?
There are two characteristic differences between these two protocols that decide which one to use in any web application services.
- REST is resource-centric whereas SOAP is operation-centric.
- SOAP web services are tightly coupled with the client. REST APIs are loosely coupled.
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.
10. How to Access REST Web Services?
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.
- We can run the REST API queries from the web browser.
- If you are using a Linux system, you can use CURL commands.
- We can access REST API resources using a GUI tool like Postman. It is also available as a browser plugin or as a stand-alone application.
11. What are the different HTTP methods used in RESTful web services?
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.|
12. What is the Difference between the POST and PUT HTML Methods?
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.
13. Which HTTP Method does support the Idempotent Rule?
The following HTTP methods obey the idempotent rule.
Below HTTP methods do not support idempotent rule.
14. Are REST web services stateless?
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.
15. How REST API different from GraphQL?
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!