Since the internet contains so many different resources, they all should be accessible via URIs and should be identified uniquely. Furthermore, the URIs can be in a human-readable format, despite the fact that their consumers are more likely to be software programs rather than ordinary humans.
Human-readable URIs keep data self-descriptive and ease further development against it. This helps you to keep the risk of logical errors in your programs to a minimum.
Here are a few sample examples of such URIs representing different resources in a catalog application:
- http://www.mycatalog.com/categories/watches
- http://www.mycatalog.com/categories/watches?collection=2018
- http://www.mycatalog.com/categories/watches/model-xyz/image
- http://www.mycatalog.com/categories/watches/model-xyz/video
- http://www.mycatalog.com/archives/2017/categories/watches.zip
These human-readable URIs expose different types of resources in a straightforward manner. In the preceding example URIs, it is quite clear the data is items in a catalog, which are categorized watches. The first link shows all the items in the category. The second shows only the ones that are part of the 2018 collection. Next is a link pointing to the image of the item, followed by a link to a sample video. The last link points to a resource containing items from the previous collection in a ZIP archive. The media types served per each URI are rather easy to identify, with the assumption that the data format of an item is either JSON or XML, so we can easily map the media type of a self-described URL to one of the following:
- JSON or XML documents describing the items
- Images
- Videos
- Binary archive documents