Trusted answers to developer questions

RESTful web services

Get Started With Machine Learning

Learn the fundamentals of Machine Learning with this free course. Future-proof your career by adding ML skills to your toolkit — or prepare to land a job in AI or Data Science.

RESTful web services are web services based on the REST, or REpresentational State Transfer, architecture. REST architecture is a web standard that specifies a set of constraints. REST treats every component (data and functionality) as a resource that can be accessed using standard methods. Due to this standardization, RESTful web services provide interoperability across computer systems on the Internet as well as other desirable properties like performance, scalability, and modifiability.

RESTful web services use HTTPHTTP methods are used to access resources.. Some common methods are GET, POST, PUT, and DELETE.

Principles

RESTful applications follow these principles:

  • Resource identification through the Uniform Resource Identifier (URI)a string of characters that unambiguously identifies a particular resource.:
    Every resource or object has its own specific URI for global addressing and service discovery.
  • Uniform interface:
    Resources should only be manipulated using the HTTP methods: GET, POST, PUT, and DELETE.
  • Self-descriptive messages:
    Resources are decoupled from their representation and their content can have a variety of formats.
  • Stateful interactions through hyperlinks:
    All interactions with a resource are stateless. Instead, each request must contain all of the information necessary to understand the request.

Example

Let’s consider an example of a web service that provides weather information using the REST architectural style.

Interacting with a web service
Interacting with a web service

The web service server provides a REST interface and a weather resource that has the URI, /service/weather.

The client makes an HTTP POST request in JSON format to get the weather for the city of Paris. The server responds with an HTTP POST response JSON object that has the weather information.

RELATED TAGS

rest
restful
web services
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?