APIGEE-API-ENGINEER practice question 15 of 25

You are adding a filter on an API to locate all orders in a specific date range You want to use a RESTful design Which design should you use?

Full set: 126 questions
Answer options
A: GET/getOrdersBetweenDates/2016-01-01/2016-02-01
B: GET/orders'?from-date=2016-01-01&to-date=2016-02-01 Correct answer
C: GET /customers/{customer-id}/orders'?from-date=2016-01-01&to-date^2016-02-01
D: POST /searchorders with a post-body of from-date-2016-01-01&to-date=2016-02-01
Correct Answer:
B. GET/orders'?from-date=2016-01-01&to-date=2016-02-01
Explanation

This design correctly follows RESTful principles for filtering a collection of resources. It uses the GET HTTP method for a safe and idempotent retrieval operation. The URI path /orders clearly identifies the resource collection (all orders). Critically, it uses query parameters (?from-date=...&to-date=...) to apply the filter, which is the standard and most flexible method for filtering, sorting, or paginating a resource collection without altering the resource endpoint itself.

Why Incorrect

A. This design incorrectly includes a verb (getOrdersBetweenDates) in the URI path. In REST, the URI should identify a resource (a noun), while the HTTP method (GET) specifies the action.
C. This URI is for retrieving orders belonging to a specific customer (/customers/{customer-id}/...). The question asks to locate "all orders," making /orders the more appropriate and general resource path.
D. This option incorrectly uses the POST method. Searching or filtering data is a safe and idempotent operation that should always use the GET method. POST is typically used for creating new resources.

References

1. Google Cloud

API Design Guide. This guide

highly relevant to Apigee

specifies standard methods for API design.

Resource Names: "Collections are identified by a plural noun... GET /v1/users". This supports using /orders for the collection of all orders. (See section: Resource Names).

Filtering: "For filtering collections

this guide recommends using a filter query parameter... GET /v1/users?filter=email:@gmail.com". This supports the use of query parameters for filtering

as seen in option B. (See section: Standard Methods > List > Filtering).

2. Fielding

R. T. (2000). Architectural Styles and the Design of Network-based Software Architectures. Doctoral dissertation

University of California

Irvine.

Chapter 5

Section 5.2.1 (Client-Server): Fielding's dissertation

the foundational text for REST

describes how the uniform interface simplifies and decouples the architecture. Using GET with query parameters for filtering is a direct application of this principle

as it uses the standard interface to query a resource representation without needing a custom method or action in the URI.

3. MIT OpenCourseWare

6.170 Software Studio

Fall 2005. Lecture 21: Web Services and REST.

Slide: "RESTful URLs": The lecture material explicitly states to use "Nouns

not verbs" for URIs (e.g.

Good: /users/123

Bad: /getUser?id=123). This directly invalidates option A. It also states to "Use query strings for filtering/sorting" (e.g.

GET /users?sort=name)

which directly supports the pattern used in option B.

Scroll to Top