Deep Dive into Drupal's API Client Initiative with Brian Perry

Building an Intuitive API Client for JavaScript Developers
API Client Initiative

The Drupal community is venturing into an exciting project called the API Client Initiative. Despite various community-maintained API clients, Drupal has been missing official JavaScript utilities, a gap the initiative seeks to fill. JavaScript developers, expecting robust tools when working with a CMS, find the absence of such utilities noteworthy.

The API Client Initiative, led by Brian Perry, an initiative coordinator, aims to address this by creating a comprehensive solution that could eventually be included under the Drupal namespace on npm. 

Kazima Abbas, sub-editor of TheDropTimes (TDT), interviewed Brian Perry to gain insights into the initiative.

Based in Chicago, Illinois, Brian Perry is spearheading the Drupal API client project. His goal is ambitious, seeking ten thousand dollars to develop an extensible JavaScript API client for Drupal, intending to publish it under the Drupal namespace on npm.

Once a contributor and then an initiative coordinator of the Decoupled Menus Initiative, Brian Perry was already involved in efforts to improve Drupal's interaction with JavaScript front-ends. At DrupalCon Portland 2022, he presented the "Drupal State and the need for a JavaScript SDK" session. That initiative also published @drupal/decoupled-menu-parser and @drupal/linkset packages under the Drupal namespace on npm. The current API Client initiative can be considered as a logical progression of the same. The API Client Initiative is moving far ahead with funding from the Pitch-Burgh contest. For context, we recommend reading our earlier interview with Brian Perry here: Wish Drupal Offer an Official JavaScript Client Sometime: Brian Perry

Already making strides, Brian and his team have laid the groundwork with a proof of concept, showcasing the API client class, the Json API client, and the GraphQL client. They have garnered interest from key contributors in the decoupled Drupal ecosystem.

"I'm hoping that having a community-maintained client will allow developers to spend less time on boilerplate and more time on taking advantage of the best parts of API-first Drupal and building the things that make their decoupled project unique," states Brian.

He further emphasizes,

"I also hope our work can help influence some community standards. Our coding standards are based on Drupal's JavaScript coding standards but extended to include TypeScript."

When asked about the inspiration behind the Drupal API Client Initiative, Brian explained,

"Drupal core has great APIs to make data available to decoupled applications, but the Drupal project doesn't offer any official utilities to help JavaScript developers consume that data. 

Several similar community projects have been created to try to solve this need, but they all have different strengths and weaknesses and maintainers with different priorities and availability. 

If Drupal offered official utilities to solve this problem, not only would they be more easily discoverable for developers, but it would also make it possible for a more diverse array of contributors to inform its development."

Brian highlights the contributors who have aided in the project's refinement: Coby Sher, Pratik Kamble, Mitchell Markoff, Shruti Shende, Elber, and Abhisek Mazumdar. Brian also thanks Alex Moreno at the Drupal Association for coordinating the commitment to Pitch-burgh and spreading the word about their progress.

Coby Sher and Pratik Kamble, the co-maintainers of API Client Initiative, have played a pivotal role in the initiative's progress. They spearheaded the implementation of the initial proof of concept. Watch this space to catch a follow-up conversation with them.

"As we were putting together the proposal and refining our scope, several contributors provided feedback and helped validate some of our early concepts," Brian mentions.

He extends gratitude to individuals like shadcn, deciphered, bbrala, d34dman, johnny5th, Jay Huskins, and bradjones1.

Regarding the goals and objectives of the Drupal API Client Initiative, Brian outlines,

"Our goal is to assemble a group of contributors to combine the best of existing Drupal API clients into a set of utilities that can both address common use cases with little configuration and be extended to support the needs of a diverse JavaScript ecosystem.

As a result of our Pitchburg funding, we'll be working toward a 1.0 release of a JSON API Client. This client is intended to support all features of JSON:API in core, including all read and write operations, filtering and sorting, among others. We're also building this client in a way that can be easily extended. While we intend for the JSON:API Client to be a useful tool on its own, developers will be able to extend the JSON:API Client class to solve more specialised use cases."

The initiative aims to reach out to Drupal's JavaScript maintainers to discuss the possibility of offering these packages under the Drupal namespace on npm.

Addressing how the new Drupal API Client will cater to JavaScript developers, Brian envisions it as a package easily discoverable on NPM. He emphasizes its potential to enable developers unfamiliar with Drupal to interact more efficiently with a Drupal backend, citing built-in support for authentication as a key example.

"Not only will this give developers the option of using our utilities rather than writing their own custom code, but it should also make it clearer which authentication options can be used with Drupal's JSON:API implementation in the first place," Brian stated.

Providing updates on the current status of the initiative, Brian highlighted the recent 0.1.0 release, representing the initial proof of concept. The focus is on the ability to retrieve a collection of resources from the API, with implementations for planned configuration options like authentication, caching, and localization. Brian sought community feedback and emphasized their openness to input as they move towards the 1.0 release.

"With the POC released, we're working to spread the word and get feedback from the community. We've created a feedback issue to help guide the conversation, but we're also open to feedback in any form.

We're also moving forward with work related to our 1.0 release. We have a meta issue tracking the remaining work and plan on refining these issues as we continue our implementation."

Brian Perry
Brian Perry

Brian highlighted how the initiative benefits Drupal users and the broader community. According to him, a clearer presence on NPM will elevate Drupal's profile in the JavaScript community, meeting the expectations of developers seeking tools to consume data from the CMS.

As for opportunities for involvement, Brian extended an invitation to contribute through testing, providing feedback on the proof of concept, and engaging in the development of the 1.0 release. While acknowledging Pantheon's support, he expressed the need for a more diverse array of contributors to enhance the project's outcomes.

Brian Stated, "You also may have noted that many of our primary development contributors work together at Pantheon. While we greatly appreciate Pantheon's support and sponsorship of this project, we're also seeking help from the broader community. We're doing a decent job keeping focused on the generic use cases this project intends to solve, but having a more diverse array of contributors can only help the end result.

If you're interested in contributing, check out our project page on Drupal.org, and join us in the #api-client channel on Drupal Slack."

In providing insights into the future, Brian outlined the initiative's focus on supporting JSON:API functionality with the 1.0 release. Beyond that, potential enhancements include exploring new decoupled use cases and extending the API Client base class to support other API types like GraphQL.

"While developing the JSON:API client, we've also taken careful steps to build on top of a generic API Client class. This is intended to make it easier to support other API types in the future. For example, the API Client base class could also be extended to create a GraphQL client.

Finally, there is a substantial opportunity to improve the developer documentation related to Decoupled Drupal. What exists today is incomplete outside of a few focus areas. Using an API client as a baseline might make it easier to cover common use cases in the Drupal documentation."

The Drupal API Client Initiative emerges as a solution to a pressing need and a collaborative effort with a vision for a more accessible and robust Drupal ecosystem. As the initiative progresses, the Drupal community can expect a future where interacting with Drupal via JavaScript becomes more seamless and standardized, thanks to the collective efforts of the API Client Initiative contributors.

Disclaimer: The information provided about the interviewee has been gathered from publicly available resources. The responsibility for the responses shared in the interview solely rests with the featured individual.

Note: The vision of this web portal is to help promote news and stories around the Drupal community and promote and celebrate the people and organizations in the community. We strive to create and distribute our content based on these content policy. If you see any omission/variation on this please let us know in the comments below and we will try to address the issue as best we can.

Related Organizations

Related Drupal Initiatives

Advertisement Here

Upcoming Events

Latest Opportunities

Advertisement Here

Call for Support