reading-note

https://eng-ehabsaleh.github.io/reading-note/

View on GitHub

API design

What does REST stand for

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.

REST APIs are designed around a resources, which are any kind of object, data, or service that can be accessed by the client.

What is an identifer of a resource? it is the URI that uniquely identifies that resource

and as an example https://adventure-works.com/orders/1

What are the most common HTTP verbs

What should the URIs be based on

URIs should be based on nouns (the resource) and not verbs (the operations on the resource).

https://adventure-works.com/orders // Good

What does it mean to have a ‘chatty’ web API? Is this a good or a bad thing?

it means 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. and we should avoid that

What status code does a successful and unsuccessful GET request return?

A successful GET method typically returns HTTP status code 200 (OK). 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). The URI of the new resource is included in the Location header of the response. The response body contains a representation of the resource.

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 (No Content), indicating that the process has been successfully handled, but that the response body contains no further information. If the resource doesn’t exist, the web server can return HTTP 404 (Not Found).

ALL the above information was token from https://docs.microsoft.com/en-us/azure/architecture/best-practices/api-design