Running WordPress and Drupal as a Backend API

Learn about headless development models for decoupled architecture on Pantheon.

Contributors: Eladio Abquina, Rachel Whitton.

Discuss in our Forum Discuss in Slack

Pantheon supports running WordPress and Drupal as an API (Application Programming Interface) for the backend of headless sites, which enables the CMS to interact with external frontend applications over HTTP requests.

For example, a mobile application that uses the GET, POST, and DELETE HTTP methods to perform CRUD operations on a CMS's database .

Decoupled Architecture Overview

WordPress and Drupal are traditionally monolithic CMSs, meaning they serve as the frontend and backend of a site. Decoupled architecture (headless) is a development model that uses a CMS to manage content in the backend with a completely separate frontend component to render that content in the browser.

Some key differences of decoupled architecture include:

Decoupled Frontend

Decoupled Frontend
Presentation can be handled in a variety of ways, from interactive JS frameworks like Angular, to static generators, to mobile apps, or even another CMS. Multiple frontends can peacefully coexist.

Content Via Web Service API

Content Via Web Service API
The content for the site is accessible via a web-service API, usually in a RESTful manner and in a mashup-friendly format such as JSON.

CMS Backend and Database

CMS Backend and Database
There is a traditional database-driven CMS which editors use to maintain the content for the site, usually via the same admin interface as always.

Pantheon's Platform Benefits

Backend APIs running on Pantheon take advantage of the following platform features for optimal performance:

Exposing the Backend API

Running WordPress and Drupal as an API on Pantheon can be done on any Drupal or WordPress upstream. The process to create, update core, and launch a backend API on Pantheon does not deviate from the standard procedures.

Since WordPress 4.7, the WordPress API is included as part of core. There's no action needed to expose the API on Pantheon. Explore default routes and endpoints like /wp-json/wp/v2/posts in your browser:

default routes wp

We recommend using a trusted browser extension to format the JSON response from the API so it's easier to read.

Refer to the Rest API Handbook from WordPress.org's Developer Resources for full documentation on this web service.

Web Services are implemented through various plugins in Drupal 7.

The service module has several integration features, and other web service formats. It also has several supporting modules that extend the Drupal 7 functionalities made available to the API.

 Note

While not a REST API service by itself, you can create a JSON view using the Views Datasource module.

Frequently Asked Questions

Can I use other frameworks or distributions?

You can use custom upstreams, make your own build or install distributions that may serve as a backend API. For example, Contenta can be used on the platform.

How can I troubleshoot the backend API?

We recommend using one of the following Chrome extensions to debug HTTP requests: