
9 Designing user-friendly, interoperable operations
This chapter covers
- Designing easy-to-use requests and responses
- Filtering, sorting, and paginating lists
- Handling multiple data formats
- Erroring gracefully
- Avoiding hiding capabilities
- Standardizing operations
Imagine a Shopping API whose “Create order” (POST
/orders
) operation returns 400
Bad
Request
without further explanation for any error, such as a typo in a property name (qantity
instead of quantity
), an invalid product reference, or an unavailable product. Developers will have difficulty figuring out the problem in their code, or end users may face an unhelpful “Impossible to validate order” message.
And it’s not only error-handling that can be problematic. Despite a valid purpose, an operation’s HTTP representation, requested and returned data, and behavior can increase development time, code complexity, and error risk, and can even affect end users. Designing user-friendly, interoperable operations prevents these problems, making developers more efficient and leading them to love the API.