API / Swagger Interview questions
What is the difference between path parameters and query parameters?
Both types of parameters pass input into an operation, but they differ in where they live in the URL and, as a consequence, in what kind of data they're suited for describing.
| Path Parameter | Query Parameter |
| Embedded in the URL path: /orders/{orderId} | Appended after ?: /orders?status=shipped |
| Always required by definition. | Can be optional or required. |
| Identifies a specific resource. | Filters, sorts, or paginates a collection. |
| Typically singular per resource identifier. | Multiple query parameters can combine freely. |
A common design convention that follows from this distinction: use a path parameter when a value uniquely identifies which resource you're operating on (like an order ID), and use query parameters for anything that shapes or narrows a result set rather than identifying a single resource (like filtering, sorting, or paging through a list of orders).
More Related questions...