Preface |
|
ix | |
|
|
1 | (10) |
|
|
1 | (1) |
|
|
2 | (3) |
|
|
3 | (1) |
|
|
3 | (1) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
5 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
6 | (1) |
|
|
7 | (1) |
|
|
7 | (4) |
|
2 Identifier Design with URIs |
|
|
11 | (12) |
|
|
11 | (1) |
|
|
11 | (3) |
|
Rule: Forward slash separator (/) must be used to indicate a hierarchical relationship |
|
|
12 | (1) |
|
Rule: A trailing forward slash (/) should not be included in URIs |
|
|
12 | (1) |
|
Rule: Hyphens (-) should be used to improve the readability of URIs |
|
|
12 | (1) |
|
Rule: Underscores (_) should not be used in URIs |
|
|
12 | (1) |
|
Rule: Lowercase letters should be preferred in URI paths |
|
|
13 | (1) |
|
Rule: File extensions should not be included in URIs |
|
|
13 | (1) |
|
|
14 | (1) |
|
Rule: Consistent subdomain names should be used for your APIs |
|
|
14 | (1) |
|
Rule: Consistent subdomain names should be used for your client developer portal |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
16 | (3) |
|
Rule: A singular noun should be used for document names |
|
|
17 | (1) |
|
Rule: A plural noun should be used for collection names |
|
|
17 | (1) |
|
Rule: A plural noun should be used for store names |
|
|
17 | (1) |
|
Rule: A verb or verb phrase should be used for controller names |
|
|
17 | (1) |
|
Rule: Variable path segments may be substituted with identity-based values |
|
|
18 | (1) |
|
Rule: CRUD function names should not be used in URIs |
|
|
18 | (1) |
|
|
19 | (1) |
|
Rule: The query component of a URI may be used to filter collections or stores |
|
|
19 | (1) |
|
Rule: The query component of a URI should be used to paginate collection or store results |
|
|
20 | (1) |
|
|
20 | (3) |
|
3 Interaction Design with HTTP |
|
|
23 | (12) |
|
|
23 | (1) |
|
|
23 | (5) |
|
Rule: GET and POST must not be used to tunnel other request methods |
|
|
24 | (1) |
|
Rule: GET must be used to retrieve a representation of a resource |
|
|
24 | (1) |
|
Rule: HEAD should be used to retrieve response headers |
|
|
25 | (1) |
|
Rule: PUT must be used to both insert and update a stored resource |
|
|
25 | (1) |
|
Rule: PUT must be used to update mutable resources |
|
|
26 | (1) |
|
Rule: POST must be used to create a new resource in a collection |
|
|
26 | (1) |
|
Rule: POST must be used to execute controllers |
|
|
26 | (1) |
|
Rule: DELETE must be used to remove a resource from its parent |
|
|
27 | (1) |
|
Rule: OPTIONS should be used to retrieve metadata that describes a resource's available interactions |
|
|
27 | (1) |
|
|
28 | (5) |
|
Rule: 200 ("OK") should be used to indicate nonspecific success |
|
|
28 | (1) |
|
Rule: 200 ("OK") must not be used to communicate errors in the response body |
|
|
28 | (1) |
|
Rule: 201 ("Created") must be used to indicate successful resource creation |
|
|
28 | (1) |
|
Rule: 202 ("Accepted") must be used to indicate successful start of an asynchronous action |
|
|
29 | (1) |
|
Rule: 204 ("No Content") should be used when the response body is intentionally empty |
|
|
29 | (1) |
|
Rule: 301 ("Moved Permanently") should be used to relocate resources |
|
|
29 | (1) |
|
Rule: 302 ("Found") should not be used |
|
|
29 | (1) |
|
Rule: 303 ("See Other") should be used to refer the client to a different URI |
|
|
30 | (1) |
|
Rule: 304 ("Not Modified") should be used to preserve bandwidth |
|
|
30 | (1) |
|
Rule: 307 ("Temporary Redirect") should be used to tell clients to resubmit the request to another URI |
|
|
30 | (1) |
|
Rule: 400 ("Bad Request") may be used to indicate nonspecific failure |
|
|
30 | (1) |
|
Rule: 401 ("Unauthorized") must be used when there is a problem with the client's credentials |
|
|
31 | (1) |
|
Rule: 403 ("Forbidden") should be used to forbid access regardless of authorization state |
|
|
31 | (1) |
|
Rule: 404 ("Not Found") must be used when a client's URI cannot be mapped to a resource |
|
|
31 | (1) |
|
Rule: 405 ("Method Not Allowed") must be used when the HTTP method is not supported |
|
|
31 | (1) |
|
Rule: 406 ("Not Acceptable") must be used when the requested media type cannot be served |
|
|
32 | (1) |
|
Rule: 409 ("Conflict") should be used to indicate a violation of resource state |
|
|
32 | (1) |
|
Rule: 412 ("Precondition Failed") should be used to support conditional operations |
|
|
32 | (1) |
|
Rule: 415 ("Unsupported Media Type") must be used when the media type of a request's payload cannot be processed |
|
|
32 | (1) |
|
Rule: 500 ("Internal Server Error") should be used to indicate API malfunction |
|
|
32 | (1) |
|
|
33 | (2) |
|
|
35 | (12) |
|
|
35 | (4) |
|
Rule: Content-Type must be used |
|
|
35 | (1) |
|
Rule: Content-Length should be used |
|
|
35 | (1) |
|
Rule: Last-Modified should be used in responses |
|
|
35 | (1) |
|
Rule: ETag should be used in responses |
|
|
36 | (1) |
|
Rule: Stores must support conditional PUT requests |
|
|
36 | (1) |
|
Rule: Location must be used to specify the URI of a newly created resource |
|
|
37 | (1) |
|
Rule: Cache-Control, Expires, and Date response headers should be used to encourage caching |
|
|
37 | (1) |
|
Rule: Cache-Control, Expires, and Pragma response headers may be used to discourage caching |
|
|
38 | (1) |
|
Rule: Caching should be encouraged |
|
|
38 | (1) |
|
Rule: Expiration caching headers should be used with 200 ("OK") responses |
|
|
38 | (1) |
|
Rule: Expiration caching headers may optionally be used with 3xx and 4xx responses |
|
|
38 | (1) |
|
Rule: Custom HTTP headers must not be used to change the behavior of HTTP methods |
|
|
38 | (1) |
|
|
39 | (2) |
|
|
39 | (1) |
|
|
39 | (1) |
|
Vendor-Specific Media Types |
|
|
40 | (1) |
|
|
41 | (3) |
|
Rule: Application-specific media types should be used |
|
|
41 | (2) |
|
Rule: Media type negotiation should be supported when multiple representations are available |
|
|
43 | (1) |
|
Rule: Media type selection using a query parameter may be supported |
|
|
44 | (1) |
|
|
44 | (3) |
|
|
47 | (24) |
|
|
47 | (2) |
|
Rule: JSON should be supported for resource representation |
|
|
47 | (1) |
|
Rule: JSON must be well-formed |
|
|
48 | (1) |
|
Rule: XML and other formats may optionally be used for resource representation |
|
|
48 | (1) |
|
Rule: Additional envelopes must not be created |
|
|
49 | (1) |
|
Hypermedia Representation |
|
|
49 | (7) |
|
Rule: A consistent form should be used to represent links |
|
|
49 | (3) |
|
Rule: A consistent form should be used to represent link relations |
|
|
52 | (1) |
|
Rule: A consistent form should be used to advertise links |
|
|
53 | (1) |
|
Rule: A self link should be included in response message body representations |
|
|
54 | (1) |
|
Rule: Minimize the number of advertised "entry point" API URIs |
|
|
54 | (1) |
|
Rule: Links should be used to advertise a resource's available actions in a state-sensitive manner |
|
|
55 | (1) |
|
Media Type Representation |
|
|
56 | (12) |
|
Rule: A consistent form should be used to represent media type formats |
|
|
56 | (3) |
|
Rule: A consistent form should be used to represent media type schemas |
|
|
59 | (9) |
|
|
68 | (2) |
|
Rule: A consistent form should be used to represent errors |
|
|
68 | (1) |
|
Rule: A consistent form should be used to represent error responses |
|
|
69 | (1) |
|
Rule: Consistent error types should be used for common error conditions |
|
|
70 | (1) |
|
|
70 | (1) |
|
|
71 | (14) |
|
|
71 | (1) |
|
|
71 | (1) |
|
Rule: New URIs should be used to introduce new concepts |
|
|
71 | (1) |
|
Rule: Schemas should be used to manage representational form versions |
|
|
72 | (1) |
|
Rule: Entity tags should be used to manage representational state versions |
|
|
72 | (1) |
|
|
72 | (1) |
|
Rule: OAuth may be used to protect resources |
|
|
72 | (1) |
|
Rule: API management solutions may be used to protect resources |
|
|
73 | (1) |
|
Response Representation Composition |
|
|
73 | (5) |
|
Rule: The query component of a URI should be used to support partial responses |
|
|
74 | (2) |
|
Rule: The query component of a URI should be used to embed linked resources |
|
|
76 | (2) |
|
|
78 | (1) |
|
|
79 | (4) |
|
Rule: JSONP should be supported to provide multi-origin read access from JavaScript |
|
|
80 | (2) |
|
Rule: CORS should be supported to provide multi-origin read/write access from JavaScript |
|
|
82 | (1) |
|
|
83 | (2) |
|
|
85 | (8) |
|
|
85 | (1) |
|
|
86 | (5) |
|
Principle: REST API designs differ more than necessary |
|
|
86 | (1) |
|
Principle: A REST API should be designed, not coded |
|
|
87 | (1) |
|
Principle: Programmers and their organizations benefit from consistency |
|
|
88 | (1) |
|
Principle: A REST API should be created using a GUI tool |
|
|
89 | (2) |
|
|
91 | (2) |
Appendix: My First REST API |
|
93 | |