Where Do Resources Come From?

Here is the approach I used in my session at the Colorado Software Summit on REST (I will post the slides over the weekend) to find resources.

Finding Resources

  • Domain Nouns: This is the most natural approach for finding resources, but it can end up with an inconvenient resource model. For instance, the NYT Movie Reviews API has things like Movies, Reviews, Critics, Critic's picks, Reviews by reviewer identified as resources. These can provide a good starting point, but may not meet the needs of client apps, which leads to the next step.
  • Composites: These are combinations of other resources, created primarily to address client app needs. Composites can also fix the urge for batching. An example is "a user profile with 5 contacts plus favorite colors plus 10 latest updates" identified as a single resource, so that the client developer can get with a single GET.
  • Tasks and Processes: An example is an account transfer with some back-end process to complete the transfer at the end of the business day. Some in the audience wondered if it is RESTful to identify such an account transfer "process" (something that is typically identified as a verb). But why not? Such processes can be resources themselves with their own state and lifecycle.

Write a Comment


  1. Subbu:

    I thought, I’d chime in about the last one.

    a) I find it quite ironic to think that a business process is no more than a series of resources interacting as part of their lifecycle (debit, transfer and credit) and the REST camp is now inventing “process” resources when they would have otherwise the absolute right foundation if only they could understand that resources have indeed a lifecycle made up of states and transitions and that there is indeed an action based “API” to transition resources from one state to another. So please, before you guys mess up the BPM space like Assaf et al in its time, I would urge you to think Resourcefully about it.

    b) the example that you are providing is extremely interesting from a REST perspective because it shows how impractical the artificial network authority boundary is. Let’s say I really want to create a RESTful transfer. How could I go about doing that.

    I need to
    1) POST a “debit” resource to an account
    2) POST a “transfer” resource to this debit
    3) Let’s that somehow you achieve transactionality and you can’t create a debit without a transfer and vice versa
    4) Now, I need to POST a “credit” resource to the transfer, but does it belong to the transfer resource or the receiving account? How do I achieve transactionality again between the receiving account, the transfer and the credit resource?

    Now that the transfer has been completed how do you update the debit and credit resources?

    It would be really interesting to see a full RESTful implementation of this use case.


  • Related Content by Tag