Getting URL Alias For Referenced Entity With RESTful API in Drupal
As documented in a previous post, with RESTful, you can create a separate API endpoint to look up the base node ID from a URL alias for a specific entity. However, there are also URL aliases for other entities that are referenced from within your base entity, such as users and taxonomy terms. We don't want to have to do a separate lookup for each of these entities outside of our base entity, so the ideal situation would be to just have a field returned within our base entity lookup that contains these URL aliases.
Creating a RESTful API URL Alias Lookup in Drupal
Over the past few months (since Drupalcon LA), I have been actively diving in to the world of decoupled Drupal, in particular using AngularJS as a front end. After going through many tutorials and looking at the multiple options for providing an API from Drupal to be consumed by Angular, I settled on using the RESTful module. One thing I like in particular about it is that you have to explicitly define what you want available in your API, as compared to everything being automatically being made available when the module is enabled. Another great feature I discovered is that you can also easily create custom endpoints that expose data from custom database queries. A perfect example of this is looking up an entity id from a URL alias.