What does REST stand for?
In 2000, Roy Fielding proposed Representational State Transfer (REST) as an architectural approach to designing web services. REST is an architectural style for building distributed systems based on hypermedia. REST is independent of any underlying protocol and is not necessarily tied to HTTP. However, most common REST API implementations use HTTP as the application protocol, and this guide focuses on designing REST APIs for HTTP.
A primary advantage of REST over HTTP is that it uses open standards, and does not bind the implementation of the API or the client applications to any specific implementation. For example, a REST web service could be written in ASP.NET, and client applications can use any language or toolset that can generate HTTP requests and parse HTTP responses.
REST APIs are designed around a resources.
What is an identifer of a resource? Give an example.
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:
https://adventure-works.com/orders/1
What are the most common HTTP verbs?
REST APIs use a uniform interface, which helps to decouple the client and service implementations. For REST APIs built on HTTP, the uniform interface includes using standard HTTP verbs to perform operations on resources. The most common operations are GET, POST, PUT, PATCH, and DELETE.
What should the URIs be based on?
Focus on the business entities that the web API exposes. For example, in an e-commerce system, the primary entities might be customers and orders. Creating an order can be achieved by sending an HTTP POST request that contains the order information. The HTTP response indicates whether the order was placed successfully or not. When possible, resource URIs should be based on nouns (the resource) and not verbs (the operations on the resource).
Give an example of a good URI.
https://adventure-works.com/orders // Good
What does it mean to have a ‘chatty’ web API? Is this a good or a bad thing?
Another factor is that all web requests impose a load on the web server. The more requests, the bigger the load. Therefore, try to avoid “chatty” web APIs that expose a large number of small resources. Such an API may require a client application to send multiple requests to find all of the data that it requires. Bad thing
What status code does a successful GET request return?
A successful GET method typically returns HTTP status code 200 (OK).
What status code does an unsuccessful GET request return?
If the resource cannot be found, the method should return 404 (Not Found).
What status code does a successful POST request return?
If a POST method creates a new resource, it returns HTTP status code 201 (Created).
What status code does a successful DELETE request return?
If the delete operation is successful, the web server should respond with HTTP status code 204, indicating that the process has been successfully handled, but that the response body contains no further information.