Understanding the necessity of how a protocol works between a client and a server allows for an application to be supported from multiple enviornments and allows for greater use of the applications.
Representational State Transfer (REST) is an architectural approach to designing web services. 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.
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:
https://adventure-works.com/orders/1
HTTP verbs perform operations on resources and the most common are GET, POST, PUT, PATCH, and DELETE.
When possible, resource URIs should be based on nouns (the resource) and not verbs (the operations on the resource). An example:
https://adventure-works.com/orders
// Good
https://adventure-works.com/create-order
// Avoid
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.
A successful GET method typically returns HTTP status code 200 (OK).
If the resource cannot be found, the method should return 404 (Not Found).
If a POST method creates a new resource, it returns HTTP status code 201 (Created).
If the delete operation is successful, the web server should respond with HTTP status code 204 (No Content), indicating that the process has been successfully handled, but that the response body contains no further information.
What are the requisite JS components for building a site utilizing an API and are there different templates for developers to use?