PHPackages                             hussainweb/drupal-api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. hussainweb/drupal-api-client

ActiveLibrary[API Development](/categories/api)

hussainweb/drupal-api-client
============================

Convenient wrapper on Guzzle to access Drupal.org API

v2.1.1(2y ago)148.8k↑300%6[1 PRs](https://github.com/hussainweb/drupal-api-client/pulls)GPL-2.0-or-laterPHPPHP &gt;=8.0CI failing

Since Feb 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/hussainweb/drupal-api-client)[ Packagist](https://packagist.org/packages/hussainweb/drupal-api-client)[ RSS](/packages/hussainweb-drupal-api-client/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (10)Versions (10)Used By (0)

Drupal.org API client
=====================

[](#drupalorg-api-client)

[![Latest Version](https://camo.githubusercontent.com/a51dd35447f87c173d2694350f781baf8a1db3475ce954a4f3f01677ed10e409/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6875737361696e7765622f64727570616c2d6170692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://github.com/hussainweb/drupal-api-client/releases)[![Software License](https://camo.githubusercontent.com/d29b73b73c0d974cb5bda74c0d50ee9ea5be2439cbdb9d6cda893d351e41a824/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c76322d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/41a15f02c4fcf9fb89ee0aa23cac7eb976c4c67008ade96fcb6144cef6669d78/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6875737361696e7765622f64727570616c2d6170692d636c69656e742f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/hussainweb/drupal-api-client)[![Total Downloads](https://camo.githubusercontent.com/918b3a754d4944235ddc610722d1d76b726d06d9d009f9a99339705b45bdd3a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6875737361696e7765622f64727570616c2d6170692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hussainweb/drupal-api-client)

This is a simple wrapper on Guzzle 6 to access and use the API provided by drupal.org. It was built for [DruStats](https://github.com/hussainweb/drupal-stats) which was built for a developer contest in DrupalCon Asia. You can refer to [DruStats](https://github.com/hussainweb/drupal-stats) for example usage.

Installation
------------

[](#installation)

Use composer to install the package.

```
composer require hussainweb/drupal-api-client:"^2.0"
```

Drupal API client version 2+ no longer depends on Guzzle. It can work with any HTTP client that implements a [HTTPlug](https://github.com/php-http/httplug) compatible ClientInterface. Here's a [list of providers](https://packagist.org/providers/php-http/client-implementation).

For example, to use Guzzle, you would need the Guzzle 6 adapter. This will install Guzzle 6 as well.

```
composer require php-http/guzzle6-adapter
```

Usage
-----

[](#usage)

The library provides a single client and multiple request classes to send requests to drupal.org API. To send a request, create a request object and call the `getEntity` method on the client class.

```
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
use Hussainweb\DrupalApi\Client;
use Hussainweb\DrupalApi\Request\UserRequest;

$config = [
    'timeout' => 2,
    // 'handler' => ...
    // ...
];
$adapter = GuzzleAdapter::createWithConfig($config);

// Retrieve user with uid 314031.
$client = new Client($adapter);
$user_request = new UserRequest('314031');
$user = $client->getEntity($user_request);
```

The above example uses [Guzzle 6 Adapter](http://docs.php-http.org/en/latest/clients/guzzle6-adapter.html) but any HTTP client implementing php-http based clients will work. Construct the HTTP client and pass it when constructing the `Hussainweb\DrupalApi\Client` class.

There are various request classes to retrieve different types of entities and entity listings. Many of the entity request classes have a corresponding list request class as well, e.g. `CommentRequest` and `CommentCollectionRequest`.

### User Agent

[](#user-agent)

In accordance with responsible usage of Drupal.org API, it is important to set the user-agent header to indicate your application. You may set this request once globally using the static property on the `Request` class.

```
Request::$userAgent = 'Drupal Statistics Collector';

```

You have to do this only once as this user-agent is applied to all child requests as well. See the test in `\Hussainweb\DrupalApi\Tests\Request\RequestTest::testRequestUserAgent` for verifying the behaviour.

Note on HTTP client implementations
-----------------------------------

[](#note-on-http-client-implementations)

As noted above, Drupal API Client version 2+ no longer depends on Guzzle but any HTTP client which provides a [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation). This is a PSR-18 compatible HTTP client interface and you can read more about it at [HTTPlug](https://github.com/php-http/httplug).

Since PSR-18 has been implemented in a different provider ([psr/http-client-implementation](https://packagist.org/providers/psr/http-client-implementation)), this client might move to that in the near future. Right now, almost all clients that support the HTTPlug interface also supports the PSR-18 interface and you would be able to use that client right now. The only notable exception is Guzzle 7 but there is [discussion to add support for that in an adapter](https://github.com/php-http/guzzle6-adapter/pull/72).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 98.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~352 days

Recently: every ~656 days

Total

9

Last Release

984d ago

Major Versions

0.9.3 → 1.02016-08-13

1.x-dev → v2.0.02020-07-27

PHP version history (3 changes)0.9PHP &gt;=5.5.9

v2.0.0PHP &gt;=7.1

v2.1.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1040271?v=4)[hussainweb](/maintainers/hussainweb)[@hussainweb](https://github.com/hussainweb)

---

Top Contributors

[![hussainweb](https://avatars.githubusercontent.com/u/1040271?v=4)](https://github.com/hussainweb "hussainweb (62 commits)")[![deviantintegral](https://avatars.githubusercontent.com/u/255023?v=4)](https://github.com/deviantintegral "deviantintegral (1 commits)")

---

Tags

apidrupal

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hussainweb-drupal-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/hussainweb-drupal-api-client/health.svg)](https://phpackages.com/packages/hussainweb-drupal-api-client)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k28.0M318](/packages/openai-php-client)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[gotenberg/gotenberg-php

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

3856.2M31](/packages/gotenberg-gotenberg-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
