Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Cms 2.1.4 Update released for Drupal core (2.1.4)! Release: Drupal 12.0.0-alpha1 First alpha version released for Drupal core (12.0.0-alpha1). Release: PhotoSwipe - Responsive JavaScript Modal Image Gallery 5.0.9 Minor update available for module photoswipe (5.0.9). Release: AI (Artificial Intelligence) 1.4.8 Minor update available for module ai (1.4.8). Release: AI (Artificial Intelligence) 1.3.13 Minor update available for module ai (1.3.13). Release: Moderated Content Bulk Publish 2.0.53 Minor update available for module moderated_content_bulk_publish (2.0.53). Release: Mailchimp 2.2.9 Minor update available for module mailchimp (2.2.9). Release: Mailchimp 3.1.4 Minor update available for module mailchimp (3.1.4). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Module Revived: Block Token 8.x-1.3 Module block_token updated after 18 months of inactivity (8.x-1.3).

Dolibarr API

No security coverage Drupal 10–11 PHP >=8.1
View on drupal.org

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 dolibarr_api_swagger.json, 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} (e.g. 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.

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
6 hours ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

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