Drupal API Client
Welcome to the Drupal API Client documentation!
What is the Drupal API Client?
Section titled “What is the Drupal API Client?”The Drupal API Client is a set of JavaScript packages that simplify the process of interacting with common Drupal APIs. Most commonly, developers will use our JSON:API client to interface with Drupal’s JSON:API endpoints, but we also publish a base API Client package that can be extended, a client for Decoupled Router, and may support other Drupal APIs in the future.
The Drupal API Client takes great care to be framework-agnostic and universal. It can be used:
- with your JavaScript framework of choice, vanilla JavaScript, or even in Drupal itself.
- with or without TypeScript.
- on the server, or on the client.
- with a bundler, or as a script import from a CDN.
Hello Umami!
Section titled “Hello Umami!”Below is a simple example that uses @drupal-api-client/json-api-client to list the titles of all articles in Drupal’s Umami Demo Profile. What you see below is a live example sourcing data from a Drupal instance at build time.
---import { JsonApiClient } from "@drupal-api-client/json-api-client";
const client = new JsonApiClient( "https://drupal-api-demo.party",);const articles = await client.getCollection("node--article");---<h2>Umami Articles</h2><ul> {articles.data.map((article) => ( <li key={article.id}>{article.attributes.title}</li> ))}</ul>Continue on to dig deeper in to what is possible with the client.