Drupal API Client
Welcome to the Drupal API Client documentation!
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!
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.
Umami Articles
- Give it a go and grow your own herbs
- Dairy-free and delicious milk chocolate
- The real deal for supermarket savvy shopping
- The Umami guide to our favorite mushrooms
- Let's hear it for carrots
- Baking mishaps - our troubleshooting tips
- Skip the spirits with delicious mocktails
- Give your oatmeal the ultimate makeover
---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.