PHPackages                             ecourty/data-gouv-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. ecourty/data-gouv-client

ActiveLibrary[API Development](/categories/api)

ecourty/data-gouv-client
========================

A PHP client library for the data.gouv.fr API.

v1.0.0(2w ago)00[1 PRs](https://github.com/EdouardCourty/data-gouv-client/pulls)MITPHPPHP &gt;=8.4CI passing

Since May 23Pushed 1w agoCompare

[ Source](https://github.com/EdouardCourty/data-gouv-client)[ Packagist](https://packagist.org/packages/ecourty/data-gouv-client)[ RSS](/packages/ecourty-data-gouv-client/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (5)Used By (0)

data-gouv-client
================

[](#data-gouv-client)

[![CI](https://github.com/EdouardCourty/data-gouv-client/actions/workflows/ci.yml/badge.svg)](https://github.com/EdouardCourty/data-gouv-client/actions/workflows/ci.yml)

A typed PHP 8.4 client for the [data.gouv.fr](https://www.data.gouv.fr) API, auto-generated from the official Swagger specification.

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Authentication](#authentication)
- [Sub-clients](#sub-clients)
- [Configuration](#configuration)
- [Examples](#examples)
- [Development &amp; Contribution](#development--contribution)

---

Requirements
------------

[](#requirements)

- PHP 8.4+
- Composer

---

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

[](#installation)

```
composer require ecourty/data-gouv-client
```

---

Quick Start
-----------

[](#quick-start)

```
use Ecourty\DataGouv\DataGouv\DataGouvClient;

$client = new DataGouvClient();

// Access sub-clients via PHP 8.4 property hooks — no parentheses needed
$page = $client->datasets->listDatasets(['q' => 'budget', 'page_size' => 10]);

foreach ($page->getData() as $dataset) {
    echo $dataset->getTitle() . "\n";
}
```

---

Authentication
--------------

[](#authentication)

An API key is **optional for read operations** and **required for write operations**.

Get your key from your [data.gouv.fr profile](https://www.data.gouv.fr/fr/admin/me/).

```
$client = new DataGouvClient(apiKey: 'your-api-key');

$me = $client->me->getMe();
echo $me->getFirstName() . ' ' . $me->getLastName();
```

---

Sub-clients
-----------

[](#sub-clients)

Each API category is exposed as a typed property on `DataGouvClient` using **PHP 8.4 virtual property hooks** — access them directly, no method call needed.

PropertyDescription`$client->datasets`Datasets`$client->organizations`Organizations`$client->reuses`Reuses`$client->dataservices`Dataservices (APIs)`$client->users`Users`$client->me`Authenticated user profile`$client->discussions`Discussions`$client->harvest`Harvest sources`$client->tags`Tags`$client->posts`Blog posts`$client->site`Site-level info`$client->spatial`Spatial / geographic data`$client->notifications`Notifications`$client->transfer`Transfers`$client->reports`Reports`$client->contacts`Contacts`$client->visualizations`Visualizations`$client->accessType`Access types`$client->avatars`Avatars`$client->proconnect`ProConnect`$client->workers`Background workers---

Configuration
-------------

[](#configuration)

```
use Ecourty\DataGouv\DataGouv\DataGouvClient;
use Symfony\Component\HttpClient\Psr18Client;

$client = new DataGouvClient(
    apiKey: 'your-api-key',      // optional — required for write operations
    httpClient: new Psr18Client(), // optional — defaults to auto-discovered PSR-18 client
);
```

The base URL and API key header name are available as typed constants:

```
DataGouvClient::BASE_URL;       // 'https://www.data.gouv.fr/api/1'
DataGouvClient::API_KEY_HEADER; // 'X-API-KEY'
```

---

Examples
--------

[](#examples)

Runnable examples are in the `examples/` directory:

```
# List datasets
php examples/list-datasets.php
php examples/list-datasets.php "budget"

# List organizations
php examples/list-organizations.php "ministère"

# Fetch a dataset and its resources by ID
php examples/dataset-resources.php 5906c1ed88ee386cdb3873a4

# List dataservices (APIs)
php examples/list-dataservices.php "statistiques"

# Authenticated user profile (requires API key)
DATA_GOUV_API_KEY=your-key php examples/authenticated-user.php
```

---

Development &amp; Contribution
------------------------------

[](#development--contribution)

### Setup

[](#setup)

```
git clone https://github.com/EdouardCourty/data-gouv-client
cd data-gouv-client
composer install
```

### Regenerate from the API spec

[](#regenerate-from-the-api-spec)

The library is generated from the live Swagger spec. To regenerate:

```
composer generate           # full pipeline (patch spec → Jane → patch normalizers → facade → cs-fix)
composer generate:patch-spec      # download & patch the Swagger spec (fixes nullable fields)
composer generate:client          # run Jane PHP (generates models + raw HTTP client)
composer generate:patch-generated # fix DateTime parsing in generated normalizers
composer generate:facade          # generate sub-clients + DataGouvClient facade
```

> **Do not manually edit** `src/DataGouv/Client/`, `src/DataGouv/Api/`, or `src/DataGouv/DataGouvClient.php`.
> These files are fully generated. To change their output, edit the scripts in `bin/` and re-run `composer generate`.

### QA

[](#qa)

```
composer test              # all tests (unit + integration)
composer test-unit         # unit tests only
composer test-integration  # integration tests (hits the real API)
composer phpstan           # static analysis
composer cs-check          # code style check
composer cs-fix            # auto-fix code style
composer qa                # phpstan + cs-check + all tests
```

### Contributing

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Make your changes (update `AGENTS.md` and `README.md` if needed)
4. Ensure `composer qa` passes
5. Open a pull request

---

*This client is auto-generated from the [data.gouv.fr Swagger spec](https://www.data.gouv.fr/api/1/swagger.json).*

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance97

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.6% 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

Unknown

Total

1

Last Release

17d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3150ffb131124e5f03272d9ed8084c514f18fff6aafff1a5973c016993f6ef66?d=identicon)[ecourty](/maintainers/ecourty)

---

Top Contributors

[![EdouardCourty](https://avatars.githubusercontent.com/u/37371516?v=4)](https://github.com/EdouardCourty "EdouardCourty (11 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

phpapiclientdata.gouv.frdata-gouv

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ecourty-data-gouv-client/health.svg)

```
[![Health](https://phpackages.com/badges/ecourty-data-gouv-client/health.svg)](https://phpackages.com/packages/ecourty-data-gouv-client)
```

###  Alternatives

[jolicode/slack-php-api

An up to date PHP client for Slack's API

2564.6M12](/packages/jolicode-slack-php-api)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

46684.5k5](/packages/deepseek-php-deepseek-php-client)[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3683.1M18](/packages/kunalvarma05-dropbox-php-sdk)[openai-php/symfony

Symfony Bundle for OpenAI

219807.4k3](/packages/openai-php-symfony)[jolicode/harvest-php-api

An up to date PHP client for Harvest's API

2265.4k](/packages/jolicode-harvest-php-api)[google-gemini-php/symfony

Symfony Bundle for Gemini

1412.3k2](/packages/google-gemini-php-symfony)

PHPackages © 2026

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