As of Q3 2015, the CIFER Project has been transitioned to the TIER-Data Structures and APIs Working Group.
About the CIFER API Framework
These are uniform API conventions adopted by teams working across CIFER APIs. It provides a reference for current and future contributors to the set of CIFER APIs.
REST as Reference Style for CIFER API Framework
This framework references Representational State Transfer (REST), where a service is composed of an addressable set of resources. URLs are used to address resources and transitions of a resources state are accomplished by direct, stateless client interactions with these URLs.
Clients of the service may:
- Search for resources
- Get a representation of a resource
- Add or replace a resource
- Delete a resource
Authentication and Authorization
The framework does not specify authentication or authentication methods. Some acceptable methods include:
- Basic auth over https
- Client certificate auth over https
- Oauth Bearer tokens over https
- Encrypted and signed content over any transport
API
Grammar and Format Constraints
URI syntax
A major version of a particular CIFER API must be indicated in the URI path (for example, “/v2/”). A major version will differentiate incompatible representations, parameters or headers. A major version change is also indicated by a change in field type.
(Any minor version will be indicated in the response metadata not in the URI path (see response section below).
Request/response grammar
Javascript Object Notation (JSON) is standard for request and responses.
XML may be used as an additional response format but is not required.
Data and field formats
- UTF-8 is the character set encoding.
- Timestamp representations will comply with ISO 8601. For example, “2014-03-04T23:20:28Z” represents a time and “PT1.81S” represents a time duration.
- Attribute names are camelCase (including acronyms). For example, "selfUri".
- Enum and other fixed attribute values should be camelCase.
- Attribute names must conform to the following ABNF [RFC5234 ] rules:
- ATTRNAME = ALPHA *(nameChar)
- nameChar = "-" / "_" / DIGIT / ALPHA
- Attribute types must stay consistent within a major version.
- Objects are identified by uri: e.g.: netId:mchyzer, or userId:12345678
- Where a hierarchy is required within a path element, the colon (“:”) should be used as a separator.
Requests
Resource references
CIFER APIs accommodate large responses by recognizing full and partial resources.
- A full resource, where the response is the full resource requested, must be identified by a URI only, not by query string or fragment.
- A partial resource, like a response that is better served across pages, is identified by a URI that contains at least one additional query string parameter (see paging options in query string options section below).
- Because of their disconnected nature, paged resources may be incomplete or inconsistent.
Request methods
- The request method of POST may be overridden by an HTTP header (see header options below)
- A PUT request need not specify all attributes.
- Replacing a resource will not affect attributes not specified in the request.
- A necessary attribute not specified will return an error 400 (see response codes below).
- Search requests return resource URIs and default resource attributes.
- Each service must document the default fields returned on each search request type.
- Search requests may use a number of query string options to accomplish paging operation, response field selection and other search request extensions (see query string options section below).
HTTP header options
- The request method of POST may be overridden by the header:
- X-HTTP-Method-Override: GET | PUT | DELETE
- XML representation of resources are not required, but may be requested by the header:
- Accept: text/xml
- ETag and If-Match may be used given the following constraints:
- A request to add a resource must not specify an If-Match header.
- A request to replace a resource must specify an If-Match header.
- The ETag value provided by the client must either match the resource's current ETag value, or the ETag value must contain a “match any” wildcard (as with “*”, where acceptance of the wildcard is service dependent).
- A client may request to "act as" another user via the header:
- X-CIFER-Act-As: user_uri
- A client may define or override a request header with a query string parameter, e.g.:
- "&Accept=application%2Fjson"
Specifying Attributes
Requests may request specific attributes in the returned resources with the query string parameters:
- *&attributes=*attribute1,attribute2,...
- Include only these attributes
- *&extraAttributes=*attribute1,attribute2,...
- Include these in addition to the default
- *&omitAttributes=*attribute1,attribute2,...
- Remove these default attributes from the response
- A request for unknown attributea will not cause an error.
- Support of this feature is optional.
Pagenation and sort order
Requests for large resources, like membership in a large group, may specify paging query string parameters :
- sortBy: name of attribute
- sortOrder: “a*” or “A” for ascending, or “'d*” or “D” for descending
- count: number of entries per page, zero means no paging
- startIndex: row number of the first resource,
- startPage: page number, starting with zero
- startValue: first value returned will be the one after this value
- value is the value of the sortBy attribute
A service may provide default paging parameters, and may reduce the limits requested via query string parameters.
Misc
- A client may request a pretty-printed response using:
- &indent=true
- The meaning o{*}f '*indent' is up to the service.
- Boolean parameters should be generously interpreted:
- e.g.: true|false”, “t|f”, “yes|no”, “y|n”, “1|0”
- Undefined query string parameters will not cause an error.
Root and application information resources
While most browser facing web sites are nowadays discoverable from the root resource, there never was a time when an application could be completely discovered through its API.
- The complexity of resources, authorizations, capabilities, and interactions requires, often extensive, external documentation of the application.
- To be efficient a client often must be able to directly address a resource.
These considerations indicate that a root resource, with links to version resources, with links to other resource URLs will in almost all cases be bypassed by clients. User readable API documentation will specify direct, if relative, links directly to most of the individual resources.
The framework does not specify these root and directory representations, except that they follow the general request and response guidelines. A root page may be used to provide general information about the application instance: what version it supports; whether or not it supports XML representation; etc.
Responses
Response structure
Resources are returned along with metadata about the resource, request and response (see JSON examples that follow)
ciferMeta:
Individual ciferMeta attributes are optional.
- lastModified: timestamp when the resource was modified
- selfUri: URI to the current resource
- ETag, or equivalent, for resources that can be replaced
- responseTimestamp: when the response was issued
- responseTime: time that the server took in processing this request
- requestCommentary: freeform text about the request that the server processed (for debug)
- httpStatusCode: response status as an HTTP status code.
- serverVersion: major.minor server version number
- pagenation: (echo of requested pagenation and sort parameters)
Response codes
- 200: the resource was found
- 201: the resource was created
- 400: the request was not valid
- 401: the client was unauthenticated
- 403: an authenticated client was not authorized for the request
- 404: requested resource was not found
- 406: service cannot provide requested XML representation
- 409: (conflict)
- PUT to an existing resource without an If-Match
- 412: (precondition failed)
- If-Match header did not match resource's ETag, or
- If-Match header supplied but resource not found (add with an If-Match), or
- wildcard If-Match not allowed
- 500: server error
JSON syntax examples
example site directory
{ "people": "/people", "places": "/places", "ciferMeta":{ "lastModified":"2012-11-04T09:57:03.541Z", "baseUri":"https://example.u.edu/ppservice/v1/", "responseTimestamp":"2013-07-04T09:57:03.541Z", "httpStatusCode":200, "responseTime":"P0.011S", "serverVersion":"1.1" } }
example search resource
{ [ {"uuid": "3ac85497-1663-4ef4-9933-3df8bc7800bc", "lastName": "Doe", "givenName": "John A.", "address": { ... } "status": "something", "uri": "/v1/people/3ac85497-1663-4ef4-9933-3df8bc7800bc" }, {"uuid": "3ac85497-1663-4ef4-9933-3df8bc7800cc", "lastName": "Doe", "givenName": "John B.", "address": { ... } "status": "something", "uri": "/v1/people/3ac85497-1663-4ef4-9933-3df8bc7800cc" }, ], "ciferMeta":{ "baseUri":"https://example.u.edu/ppservice", "sortOrder":"a", "pageLimit":100, "pageOffset":0, "sortField":"name", "statusCode":"SUCCESS", "responseTimestamp":"2013-07-04T09:57:03.541Z", "httpStatusCode":200, "responseTime":"P0.011S", "serverVersion":"1.1" } }