2. What Does Your API Look Like? Flashcards
What are our resources in the context of a RESTful API design?
Anything anyone wants to interact with in our system. They are “nouns.”
What should you do if there is a “hidden” resource in the process described for a RESTful API design that you’re not really sure what it is yet?
Note it down and carry on with the process, and when you have the chance, ask the product owner about it.
Having defined your resources, what is the next logical step?
List out the actions that are applicable to each resource — not a complete list for the whole system, but only for the resources in question.
eg.
• List items
• List orders
• …
What is the HTTP method GET used for?
Retrieve a resource or a collection of resources.
What is the HTTP method DELETE used for?
Delete a resource.
What is the HTTP method PUT used for?
Update an existing resource.
What is the HTTP method POST used for?
Create a new resource, change the status/state of a resource, or anything else that doesn’t fit into the GET, DELETE, or PUT method.
What HTTP method should you use for retrieving a list of resources?
GET
What HTTP method should you use for creating a resource?
POST
What HTTP method should you use for making a link between two existing resources or modify an existing link between them?
PUT
When designing a RESTful API, what should you not do in order to not cause a huge design problem?
Make things up — You should always ask the product owner what they want and never make assumptions.
What does an independent relationship mean in the context of RESTful APIs?
It means that the given resource can exist on its own without any other resources.
What does a dependent relationship mean in the context of RESTful APIs?
It means that the given resource can only exist if another resource already exists.
What does an associative relationship mean in the context of RESTful APIs?
It means that the given resource can be dependent or independent but needs additional information to describe the relationship.
What can be said about designing an API by exposing a database schema?
That it’s a bad approach because fundamentally, the choices that go into designing your database are not the same choices that go into designing your API.