Added chapter 2
All checks were successful
Build and Deploy MkDocs / deploy (push) Successful in 11s
All checks were successful
Build and Deploy MkDocs / deploy (push) Successful in 11s
This commit is contained in:
@@ -78,3 +78,23 @@ What is the purpose of building an API in the first place?
|
||||
- We could think of simplicity as the number of endpoints.
|
||||
- However an API that relies on a single `ExecuteAction()` method just shifts complexity from one place to another.
|
||||
- APIs should aim to expose the functionality users want in the most straightforward way possible, making the API as simple as possible, but no simpler.
|
||||
- **Make the common case fast**
|
||||
- Whenever you add something that might complicate the API for the benefit of an advanced user, it is best to keep this complexity hidden from a basic user.
|
||||
- This keeps the more frequent scenarios simple and easy whilst enabling advanced features for those who want them.
|
||||
- e.g. Image a translation API. `GET /translate?lang=en`, allowing the user to add a specific language model as a mandatory field is complex for the average user and will slow down basic scenarios.
|
||||
|
||||
### Predictable
|
||||
|
||||
APIs that rely on repeated patterns applied to both the API surface definition and the behaviour.
|
||||
|
||||
Users very rarely learn an entire API, they learn the parts they need to and make assumptions when they need to make additions. e.g. if a query parameter is called text in one endpoint, it should not be called string or query in another.
|
||||
|
||||
APIs that rely on **repeated**, **predictable** patterns are easier and faster to learn; and therefore better.
|
||||
|
||||
### Summary
|
||||
|
||||
- Interfaces are contracts that define how two systems should interact with one another.
|
||||
- APIs are a special type of interface
|
||||
- Web APIs are again a special type of API that is exposed over a network.
|
||||
- **Resource-oriented** APIs are a way of designing APIs to reduce complexity by relying on a standard set of actions, called *methods*, across a limited set of resources.
|
||||
- Good APIs are generally: *operational*, *expressive*, *simple* and *predictable*.
|
||||
|
||||
Reference in New Issue
Block a user