You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-study.md
+31-4Lines changed: 31 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@
9
9
*[Intro](#intro)
10
10
*[RESTful API Concepts](#rest)
11
11
-[Definitions](#rest-def)
12
+
-[Resource types](#rest-res-types)
12
13
-[Applications and Services](#rest-app)
13
14
-[API Versions](#rest-ver)
14
15
-[Resources & Collections](#rest-res)
@@ -60,6 +61,23 @@
60
61
- query: "?name=John"
61
62
- State: application state that has the resources
62
63
64
+
65
+
<aname="rest-res-types"></a>
66
+
### Resource Types
67
+
68
+
***Document**: a singular concept that is akin to an object instance or database record. e.g.: http://api.soccer.restapi.org/leagues/seattle/teams/trebuchet
69
+
70
+
***Collection**: a server-managed directory of resources. Clients may propose new resources to be added to a collection. However, it is up to the collection to choose to create a new resource, or not. Example: http://api.soccer.restapi.org/leagues/seattle/teams
71
+
72
+
***Store**: a client-managed resource repository. A store resource lets an API client put resources in, get them back out, and decide when to delete them. On their own, stores do not create new resources; therefore a store never generates new URIs. Instead, each stored resource has a URI that was chosen by a client when it was initially put into the store. Example: `PUT /users/1234/favorites/alonso`.
73
+
74
+
***Controller**: models a procedural concept.
75
+
- Controller resources are like executable functions, with parameters and return values; inputs and outputs. Like a traditional web application's use of HTML forms, a REST API relies on controller resources to perform application-specific actions that cannot be logically mapped to one of the standard methods (create, retrieve, update, and delete, also known as CRUD).
76
+
- Controller names typically appear as the last segment in a URI path, with no child resources to follow them in the hierarchy.
77
+
-**Note**: Controller resource remains argument about "resource must be a noun, instead of a verb".
78
+
- Example: `POST /alerts/245743/resend`
79
+
80
+
63
81
<aname="rest-app"></a>
64
82
### Applications and Services
65
83
@@ -146,6 +164,12 @@ A resource-oriented API is generally modeled as a resource hierarchy, where each
146
164
- `GET`, `PUT`, `PATCH`, `POST`, `DELETE` (CRUD)
147
165
- `HEAD`, `OPTIONS`, `CONNECT`, `TRACE`
148
166
167
+
* Usages:
168
+
- Checking whether a resource has changed. This is useful when maintaining a cached version of a resource (`HEAD`).
169
+
- Checking whether a resource exists and is accessible (`HEAD`, `OPTIONS`). For example, validating user-submitted links in an application.
170
+
- Retrieving metadata about the resource, e.g. its media type or its size, before making a possibly costly retrieval (`HEAD`).
171
+
- Identifying which HTTP methods a resource supports (`OPTIONS`).
172
+
149
173
* RESPONSE: representation of resource, easy to read and implemented into applications, e.g. REST XML-RPC SOAP JSON Serialized PHP
150
174
151
175
* API is like a bunch of useful methods or functions, parameters is like the parameters we can pass on to these methods
@@ -170,6 +194,7 @@ A resource-oriented API is generally modeled as a resource hierarchy, where each
170
194
| Date |RFC 5322 Date|GMT/UTC timestamp of the request.|
171
195
| Accept |Content type |(Hint of) the requested content type for the response, e.g. `application/json` or `text/javascript` (for JSONP).|
172
196
| Accept-encoding |gzip, deflate|REST endpoints SHOULD support GZIP and DEFLATE encoding, when applicable. For very large resources, services MAY ignore and return uncompressed data.|
197
+
| Allow ||List of allowed methods a resource supports, thru `OPTIONS` request, e.g. `Allow: GET,HEAD,POST,OPTIONS,TRACE`.|
173
198
| If-Match ||Only if the request matches one of listed `ETags`.|
174
199
| If-Modified-Since||Response 304 w/o body if no change; otherwise 200 w/ latest.|
0 commit comments