Web services, APIs, structured data. These things are all the rage right now and with good reason. As more and more internet enabled devices start wanting to make use of the data in our websites we need to give them some way to interact with that data that isn’t point and click in a browser. Enter the Drupal 7 services module.
In this series Joe Shindelar will walk through using the services module and teach you how to create a RESTful web services API that exposes Drupal’s internal data like nodes and users as JSON or XML that can be easily consumed by a huge variety of clients and programming languages. Paving the way for allowing access to the data contained within your Drupal site to any number of native mobile applications, partner websites, or even internet enabled refrigerators.
The first few lessons in the series are focused more on theory and explaining the various terms that are used both in Drupal and the wider web development sphere to describe web services and all the pieces. Including a description of REST itself and an explanation for why it’s a good fit. As well as some discussion about Drupal 7’s content model and the ways that it lends itself nicely to serializing data into various formats via the services module in order to be consumed in structured and meaningful ways.
Throughout the series we’ll see a couple of examples of how to first enable Drupal to return requested data elements as JSON and then subsequently how to properly format an HTTP request to retrieve those elements. Joe will demonstrate making requests to the API via both cURL and the Chrome REST Console. Doing so will help students to learn about both the Drupal configuration that is required and the way in which any 3rd party applications can request data from Drupal via concrete examples.
With the basics of creating an endpoint and making simple requests out of the way Joe will demonstrate how to enable authentication via the services module and then use both cURL and the REST Console to explain the authentication handshake. A somewhat complex exchange of a username & password for a session authentication token that takes place in HTTP requests and headers whenever you want to perform an action via the API that requires an authenticated user. Learning how this works will enable to you create 3rd party applications that can access Drupal as a specific user allowing for greater personalization.
After that Joe looks at ways to integrate the lists that site administrators create using the views module with services in order to output their contents as structured data. As wall as ways to use views to create entirely new custom services resources. Followed by an example of leveraging the power of views exposed filters via services.
Finally, for those scenarios where you simply can’t point and click your way to an answer Joe will teach you how to implement your own custom services resources for both saving and retrieving data from within Drupal. Demonstrating the basic knowledge required to allow you to use services to solve all of your own custom API needs.
Things you’ll be able to do after completion of this series:
- Understand the basic principals of both web services and RESTful APIs.
- Explain why Drupal is a good fit for web applications that want to allow 3rd party clients to access their data.
- Create a RESTful web services API using the services module for Drupal 7.
- Retrieve data from your Drupal site in both JSON and XML format.
- Create new nodes in Drupal via web services.
- Make authenticated requests to Drupal via web services.
- Integrate the views module with services to retrieve views data in various formats.
- Write your own module providing custom services data and actions.
- Create meaningful documentation that will enable others to take advantage of your newly created service.
This series provides information about the services module for both intermediate and advanced Drupal users. Since this module makes use of basic Drupal site building skills and custom views users should be familiar with those topics. Also, while not required knowledge of running commands via the command line will be helpful. Finally, if you want to write your own custom services resources you’ll need to understand basic module development.