3. How Does Your API Work? Flashcards
What are the two parts that every HTTP request and response have?
The headers and the payload.
What is a HTTP request or response’s payload?
HTML, JSON, XML…
What range of HTTP response codes indicate that the request was successful?
2xx
What does the 2xx HTTP response code series indicate?
That the request was successful.
What does the HTTP response code 200 mean?
It simply means “OK.”
What does the HTTP response code 201 mean?
It means “Created.”
What does the HTTP response code 202 mean and what is it used for?
It means “Accepted.” It’s used for identifying that the action the user just performed is underway, but it’s not complete yet.
What does the HTTP response code 204 mean, and when is it primarily used?
It means “No Content.” It’s primarily used when deleting a resource.
What does the 3xx HTTP response code series indicate?
That the resource has been moved from its original URL.
What does the HTTP response code 301 mean?
It means “Moved Permanently” as in what you’re looking for is no longer available here. Most responsible APIs will then give you the URL to then retrieve it.
What does the HTTP response code 302 mean?
It means “Moved Temporarily.”
What does the 4xx HTTP response code series indicate?
That a client error has occurred.
What does the HTTP response code 400 mean and what does it indicate?
It means “Bad Request,” denoting that the most recent attempt failed due to the client itself.
What does the HTTP response code 401 mean and what does it indicate?
It means “Unauthorized,” which indicates that the required authentication credentials were not provided or the authentication has failed.
What does the HTTP response code 403 mean and what does it indicate?
It means “Forbidden,” which indicates that the user making the request is not authorized to access the API point that’s being requested.
What does the HTTP response code 403 mean and what does it indicate?
It means “Not Found,” which indicates that the resource you’re looking for does not exist.
What does the Content-Type
HTTP header identify?
The type of the payload being provided by the server.
Are you required to follow the six constraints of RESTful API?
No. They are not hard and fast requirements but are good design principles you should follow.
What are the six architectural constraints of RESTful API?
- Client-Server Architecture
- Stateless Architecture
- Cacheability
- Idempotency
- Code on Demand
- Uniform Interfaces
What is stateless architecture and what does it allow for each request?
It’s an architectural constraint of RESTful API that states that the API should be stateless. This allows each and every request to stand on its own and be processed or rejected independently of any other request in any order that they’re received.
What is client-server architecture and what is its biggest benefit?
It’s an architectural constraint of RESTful API that states that the API should be designed for a client-server architecture. The biggest benefit of this is that it allows us to vary the implementation details, upgrade paths, and scalability of each independently of the other.
What are the characteristics/benefits of a stateless architecture for HTTP requests/responses.
- Inherent to the design of the internet
- Stability
- Scalability
- Reliability
- Flexibility
What is cacheability mean in the context of RESTful API architecture and what does it require?
It’s an architectural constraint of RESTful API that deals with whether a response pair can be cached. It requires that each message describes whether it can be cached and if so, for how long.
What is the benefit of cacheability?
It allows the API to know when it’s possible to just return the result, instead of doing the work. This improves network performance and application usage overall.