Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Dolibarr API

No security coverage Maintenance fixes only 1 sites

This module provides a typed PHP client for the Dolibarr REST API, allowing Drupal to interact with various Dolibarr resources like invoices, third parties, and products. It generates services for each API resource, making it easy to manage and access Dolibarr data securely from Drupal.

Full, typed PHP client for the Dolibarr REST API, for Drupal.
It exposes every resource of Dolibarr's Swagger specification (agenda events, invoices, thirdparties, products, contracts, proposals, supplier invoices/orders, tasks, projects, users, setup dictionaries...) as one Drupal service per resource, with one typed PHP method per API operation.

The resource classes are generated from the Swagger Explorer of the Dolibarr API module, so the whole API surface (330+ operations) is covered without hand-maintaining thousands of lines of duplicated HTTP plumbing.

Features

  • One service per Dolibarr API tag (dolibarr_api.resource.invoices,
    dolibarr_api.resource.thirdparties, ...), each with typed methods named
    after the Dolibarr operationId (listInvoices(), retrieveInvoices($id),
    createThirdparties($data), ...).
  • A single facade service (dolibarr_api) to reach any resource dynamically:
    \Drupal::service('dolibarr_api')->invoices->listInvoices().
  • Centralized, secure authentication: the DOLAPIKEY token is stored using
    the Key module, never in plain Drupal config.
  • Failures raise a DolibarrApiException (with HTTP status + decoded
    response body) and are logged to the dolibarr_api channel, instead of
    silently failing or depending on an active HTTP request (safe to use from
    Drush, cron, queues...).
  • A regeneration script (scripts/generate-resources.php) to keep the
    resource classes in sync whenever Dolibarr's API evolves.

Installation

composer require drupal/dolibarr_api
drush en dolibarr_api key -y

Configuration

  1. Create a Key at /admin/config/system/keys/add holding your Dolibarr
    DOLAPIKEY token (see Dolibarr user page to generate one, or use
    /admin/config/services/dolibarr_api/token to request one from a
    login/password pair).
  2. Go to /admin/config/services/dolibarr_api, set your Dolibarr instance
    URL and select the Key created above.

Usage

Inject a single resource (recommended)

public function __construct(
  private readonly \Drupal\dolibarr_api\Resource\InvoicesResource $invoices,
) {}

public function myMethod(): void {
  $invoices = $this->invoices->listInvoices(['thirdparty_ids' => 42]);
}

Service ID : dolibarr_api.resource.{tag}

Examples :

  • dolibarr_api.resource.invoices
  • dolibarr_api.resource.thirdparties
  • dolibarr_api.resource.products

Or use the facade for dynamic access

$dolibarrApi = \Drupal::service('dolibarr_api');
$invoices = $dolibarrApi->invoices->listInvoices([
    'thirdparty_ids' => 42,
    'limit' => 100,
    'page' => 0,
]);

Error handling

use Drupal\dolibarr_api\Exception\DolibarrApiException;

try {
  $invoices = $this->invoices->listInvoices();
}
catch (DolibarrApiException $e) {
  // $e->getStatusCode(), $e->getResponseBody() are available.
  \Drupal::logger('my_module')->error($e->getMessage());
}

Contributing

Issues and merge requests are welcome.
Please run phpcs (Drupal coding standards, see phpcs.xml.dist) and the test suite before submitting.

Drupal 10–11 PHP >=8.1

Ask your assistant about Dolibarr API

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • key Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Sep 2026
Latest release
1 month ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.0 Stable 10–11 PHP >=8.1 Sep 2, 2026
1.0.x-dev Dev 10–11 PHP >=8.1 Sep 2, 2026