Uniform Contract Elements
The REST uniform contract is based on three fundamental elements:
- resource identifier syntax - How can we express where is the data being transferred to or from?
- methods - What are the protocol mechanisms used to transfer the data?
- media types - What type of data is being transferred?
These elements are commonly represented using a triangle symbol, as shown in Figure 1.
Figure 1 - The REST triangle.
As explained shortly, individual REST services use these elements in different combinations to expose their service capabilities. However, it is important to understand that what makes this type of service contract "uniform" is the fact that a master set of these elements is defined for use by a collection (or inventory) of services. This essentially allows us to standardize the baseline elements of the service contract.
The three elements of the REST triangle are deliberately orthogonal in order to limit the impact of changes to any one element. For example, the resources for a given service inventory are defined separately from the set of methods used for that same inventory, and separately again from the set of supported media types.
Let's take a closer look at each of the uniform contract elements.