Categories

(83)
(69)
(8)
(34)
(74)
(149)

Drupal 8’s web services & awesome third-party integration opportunities

02.05.2018
Drupal 8’s web services & awesome third-party integration opportunities
Author:

Sites have truly unlimited opportunities in Drupal 8 — they are not even limited by the “website” concept! They can go far beyond it, and easily exchange data with all imaginable applications. Special opportunities for that have appeared thanks to built-in web services, which are listed among Drupal 8’s main improvements. Let’s see what web services can give you, how they work, and what extra special options are added by other Drupal 8 modules.

Web services: benefits and principles of work

The main web services role is that of a “communicator” between a Drupal website and an external application. This may mean pulling data from a Drupal website, or, vice versa, pushing it there.

Could you imagine the possible gains from outputting your website content, say, to an iOS or Android app? In addition, payment gateways, CRMs, inventory management systems, smartwatches and any other apps are ready to work with your Drupal 8 website. And that’s just the beginning of what is possible in the hands of good Drupal development agency!

Web services help websites and apps find “common language” — Drupal’s HTML data is magically transformed into the formats that are easily understandable for apps (JSON, XML, HAL+JSON, and so on).

Thanks to web services, you can create an API on your site that other apps can ask to connect to, and you can grant permissions to them. Drupal's nodes, taxonomy, collections of content (views) or other information can be fetched from your site.

A glimpse at headless Drupal

The icing on top of the cake is a headless, or decoupled Drupal approach. More and more websites are adopting it nowadays. Drupal backend, as a source of data, is combined with a front-end based on some JavaScript framework (React, Vue, Angular, Node, Ember, etc.).

In this way, JavaScript frameworks can share their best with your Drupal website! You can engage users to the maximum with dynamic features. Interactive dashboards, fast chats, push notifications are just the beginning of the list. And the speed can be fantastic!

Web services in Drupal 8

Drupal 7 and even Drupal 6 had some support for web services, but that was in the form of contributed modules.

Thanks to Web Services and Context Core Initiative (WSCCI), Drupal 8 has web services built into core, and it has been greatly enhanced.

Core Drupal 8 modules for web services

So the big integration story begins with enabling the four core Drupal 8 modules responsible for web services.

drupal modules for web services

  • The Serialization module serializes and deserializes your Drupal website data to and from formats like JSON, XML, or HAL+JSON by normalizing and encoding it.
  • The HAL module adds data normalization by means of the Hypertext Application Language.
  • The RESTful Web Services module exposes your site’s entities or other data in particular API endpoints.
  • The HTTP Basic Authentication (Basic Auth) module authenticates the username and password from a request.

Some contributed Drupal 8 modules for web services

In addition, there are extra opportunities brought by very helpful contributed Drupal modules.

This contributed module offers a handy user interface for using core web services. When it is installed and enabled, this interface appears in Configuration — Web services — REST.

Here is a module that lets API builders use GraphQL — a modern query language. This is a nice alternative to the REST architecture traditionally used for APIs. Queries are shaped by the client side precisely to get all they want immediately. Obtaining structured data (including that with a complex hierarchy) is based on the schema.

The JSON API contributed module also offers an alternative to REST. It generates an API server with the JSON API specification. According to Drupal founder Dries Buytaert, both JSON API and GraphQL could be promising modules in Drupal core some day.

The most popular module for web services in Drupal 7, the Services module has changed greatly for its 8th version. Its benefits include great API customization options, support for configuration entities, multiple response formats, etc.

While providing a RESTful API, this module offers advanced support for translations, file attachments, revisions, UUID references, opportunity for clients to subscribe to real-time change notifications, etc.

The Subrequests module we once described is a new and interesting module for Drupal 8. It groups any sets of requests together to improve performance. The JSON document named “blueprint” contains all the necessary information.

Final thoughts

All these core modules, as well as these and other contributed modules, do an awesome job! However, unlike simple cases of setting up an API, more complex ones usually require some custom code writing.

Whatever your ideas about third-party integration are, you can contact our Drupal developers. They will handle even the most complicated projects with web services.

Let your website go beyond the boundaries and give you more!

2 votes, Rating: 5

Read also

1

Drupal lets you easily integrate social networks with your website. We have shared a great collection of Drupal social media integration modules in part 1 and 2. Time flies, and we would now like...

2

You can choose one of nice, free, ready-made Bootstrap-based themes for Drupal 8. They can also be further customized to your liking — by yourself or with the help of our Drupal developers. Let’s...

3

To honor the Drupal 8.5.0 release on March 7, we will not just describe what’s new in it. Drupal 8 has already had 5 awesome minor releases: Drupal 8.1.0, Drupal 8.2.0, Drupal 8.3.0, Drupal 8.4.0...

4

This was a blog post written by guest author Martin Postma (lolandese). He usually writes directly on Drupal.org as an author of documentation. Documentation is however not included on Drupal...

5

So let’s look in detail at how the eighth version of Drupal can simplify the process of working on website content and make it a joy.

Subscribe to our blog updates