Overview

9 Designing user-friendly and interoperable operations

Designing operations that are both user-friendly and interoperable reduces development friction, limits bugs, and improves end-user experiences. This chapter explains how to make operations immediately understandable and guessable, flexible enough to fit varied use cases, and predictable across an entire API surface. It emphasizes meeting real needs with clear, visible capabilities, leveraging user-friendly data, and aiming for consistency and standardization so that developers can rely on familiar patterns and behavior everywhere.

Concretely, operations should express capabilities through meaningful, hierarchical, and predictable resource paths combined with standard HTTP methods, using globally unique identifiers to keep paths short without losing accuracy. Inputs must be easy to provide by choosing HTTP-compliant locations (path, query, headers, body), mapping inputs to outputs, preferring well-known or standard identifiers and formats, and minimizing required fields via sensible defaults or server-derived values when appropriate. Successful responses should be ready to use: return appropriate status codes and place data where developers expect it, favoring complete resource models when creating or updating. List and search endpoints should offer optional filtering, sorting, and pagination with helpful defaults and clearly returned metadata, while data adaptation can be achieved through content negotiation (formats and locale) and cautious, purpose-driven tweaks via query parameters.

Error handling is treated as a first-class design concern: limit errors by accepting reasonable input variants, use appropriate and familiar status codes, and return feedback that is both human-friendly and machine-readable, exhaustive, and actionable—optionally leveraging standardized problem formats. The chapter also warns against hiding multiple capabilities in do-it-all operations, encouraging designers to revisit granularity and purpose so each operation is clear. Finally, it calls for consistent, standardized data, features, and behaviors across operations (identifiers, response shapes, creation semantics, feature availability), producing APIs that are guessable, flexible, and dependable—making integration faster and safer for developers.

Once we have designed versatile operations that do the job, we can revisit them to ensure they’re user-friendly and interoperable. We’ll rework HTTP representations and input and output data modeling.
CH09 F01 lauret3
Consistent and interoperable user-friendly operations with appropriate granularity, HTTP representation, input, output, and helpful error handling are easily used by anyone and any system.
CH09 F02 lauret3
We question needs and leverage globally unique IDs to reduce the number of path parameters in the Banking API resources paths and make them easier to use.
CH09 F03 lauret3
Choosing user-friendly input data locations in an HTTP request depends on HTTP and common practice. Choosing appropriate locations facilitates the providing and understanding of input data.
CH09 F04 lauret3
Creating a money transfer requires input data to be put in the body to be HTTP-compliant and user-friendly.
CH09 F05 lauret3
Using a path parameter for the account identifier and query parameters for the transactions resource modifiers makes the List account transactions operation user-friendly.
CH09 F06 lauret3
We minimize money transfer inputs by determining data based on other data and using default data.
CH09 F07 lauret3
Better return the transaction complete model when listing an account’s transactions so developers have everything they need and don’t need to call Read transaction for each one.
CH09 F08 lauret3
Enabling filtering, sorting, and paginating lists is essential to allow consumers to get only the elements they need sorted as needed.
CH09 F09 lauret3
The pagination, sort, and filter metadata lets consumers know exactly what they get (especially when default parameter values are used) and if there are other available elements.
CH09 F10 lauret3
Content negotiation allows consumers to request an account’s transactions in different formats by sending a standard Accept header.
CH09 F11 lauret3
It is possible to transfer money with a JSON or XML input and get a response in JSON or XML regardless of input format
CH09 F12 lauret3
Money transfer machine-readable errors returned when sending unsupported data format or currency make it easy to show errors in UI.
CH09 F13 lauret3
The Money transfer operation performs all possible checks and returns an exhaustive list of errors, which avoids annoying back-and-forth.
CH09 F14 lauret3
An error response of the Money transfer operation leveraging and customizing the Problem Details for HTTP APIs standard
CH09 F15 lauret3

FAQ

What makes an API operation user‑friendly and interoperable?User‑friendly, interoperable operations 1) meet real consumer needs, 2) expose clear capabilities, 3) use data that’s easy to understand and provide, 4) are helpful by default (sensible defaults, ready‑to‑use outputs), 5) are consistent across the API, and 6) leverage standards (HTTP semantics, common identifiers and codes).
How do I make resource paths easy to understand and guess?Use meaningful, hierarchical, and predictable paths with standard HTTP methods. Prefer patterns like /resources, /resources/{id}, /resources/{id}/sub-resources. Keep singular/plural consistent, avoid opaque or “action” paths (for CRUD), and use globally unique IDs to shorten paths when possible. Ensure GET is safe and idempotent methods behave correctly.
When should I optimize operations for usability and interoperability?Do a second pass after you have a first draft that “does the job.” Revisit paths, inputs, and outputs together with data modeling to improve guessability, defaults, granularity, and consistency. Over time, rework decreases as you establish and follow design guidelines.
Where should I place inputs: path, query, headers, or body?Follow HTTP and common practice: use path parameters to identify the resource, query parameters for resource modifiers (filters, sort, pagination, small tweaks), headers for metadata (Accept, Content-Type, Accept-Language), and the body for resource data in POST/PUT/PATCH. Avoid cramming everything into the path or headers and don’t rely only on the body for reads.
How can I minimize required input without losing correctness?Let the server infer data when it’s safe and unambiguous, and provide helpful defaults. Examples: derive a transfer type from the presence of date/frequency; default currency from the source account; default missing dates to “today.” Don’t server‑define data that must come from the source of truth (for example, the actual timestamp of a card transaction).
What should ready‑to‑use successful responses include?Return standard HTTP statuses (for creation, 201 Created with Location) and place the representation in the response body. Prefer complete models after create/update so clients get generated/derived values immediately. For lists, return sufficiently detailed items to avoid n+1 follow‑up calls, and add metadata when useful.
How do I design filtering, sorting, and pagination?Map filters to output fields (names and types), support flexible values (enums, ranges like gte/lt, fuzzy text), keep filters optional, and offer a q parameter if needed for complex queries. Provide sort with a helpful default (for example, date:desc). Use index or cursor pagination with optional params and return list metadata (pagination, sort, applied filters, counts).
How can I support multiple formats and languages?Use content negotiation. Clients send Accept to choose response format (for example, application/json, application/xml, text/csv) and Content-Type for request bodies. Default to JSON if Accept is absent. For translations, use Accept-Language to localize human‑readable labels only; never translate property names or codes. Support the formats and locales that make sense for your use cases.
What are best practices for handling consumer errors gracefully?Prevent errors by being liberal in what you accept (ignore extra fields, accept time variants) and conservative in what you return. Use standard statuses: 400 (or 422) for validation issues, 406 for unsupported Accept, 415 for unsupported Content-Type; prefer 200 with an empty list for “no search results.” Provide human‑readable messages and machine‑readable details (location, field, pointer, generic error code) and return all errors in one response. Consider RFC 9457 Problem Details (application/problem+json).
How do I avoid hiding multiple capabilities and keep operations consistent?Check granularity: don’t overload a read with big embedded, filterable lists—offer a dedicated search. Give important actions their own operation (for example, closing an account) rather than overloading generic updates. Standardize behaviors and features across operations (statuses, headers, error format, filter/sort/paging names, list wrapper like data) and use interoperable identifiers (for example, IBAN, ISO codes).

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • The Design of Web APIs, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • The Design of Web APIs, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • The Design of Web APIs, Second Edition ebook for free