Daily Reading 8
APIs
API Design Best Practices
What does REST stand for?
REpresentational State Transfer.
REST APIs are designed around a __.
Resource, which is any kind of data, object, or service that a client can access.
What is an identifier of a resource? Give an example.
Uniform Resource Identifier (URI) is the name aspect of a URL, the identifying “HTTP://” of where a resource lives.
What are the most common HTTP verbs?
GET, POST, PUT, PATCH, DELETE.
What should the URIs be based on?
Nouns, and NOT the action. Order, not Make An Order.
Give an example of a good URI.
blank dot com/forecast
What does it mean to have a ‘chatty’ web API? Is this a good or a bad thing?
An API is chatty if it makes lots of large requests frequently, when the same desired result could potentially be achieved with much less frequent, and smaller requests.
What status code does a successful GET request return?
200 OK
What status code does an unsuccessful GET request return?
Codes in the 400 range, the specific cod depends on what way the get request failed. (404 for “asking for something that doesn’t exist,” 403 for “You’re not allowed access to this,” etc.)
What status code does a successful POST request return?
201 CREATED if the post has succeeded in making a new resource.
What status code does a successful DELETE request return?
204 NO CONTENT (There used to be content here, but now it is deleted, and thus there is nothing.)