|
| 1 | +--- |
| 2 | +title: Publish to data.gouv.fr |
| 3 | +weight: 6 |
| 4 | +--- |
| 5 | + |
| 6 | +# How to publish datasets to data.gouv.fr |
| 7 | + |
| 8 | +This guide explains how to configure your collection to automatically publish datasets to [data.gouv.fr](https://www.data.gouv.fr/), the French government's open data platform. |
| 9 | + |
| 10 | +## Prerequisites |
| 11 | + |
| 12 | +- A [data.gouv.fr](https://www.data.gouv.fr/) account |
| 13 | +- An API key from your data.gouv.fr account settings |
| 14 | +- Either an existing dataset or an organization where you can create datasets |
| 15 | + |
| 16 | +## Choose your approach |
| 17 | + |
| 18 | +There are two ways to publish datasets to data.gouv.fr: |
| 19 | + |
| 20 | +### Option 1: Automatically create a dataset in an organization |
| 21 | + |
| 22 | +This approach is suitable when you want the system to automatically create and manage the dataset within your organization. |
| 23 | + |
| 24 | +1. Find your organization on [data.gouv.fr](https://www.data.gouv.fr/) (or [demo.data.gouv.fr](https://demo.data.gouv.fr/) for testing) |
| 25 | +2. Copy the organization ID or slug from the URL (e.g., `open-terms-archive`) |
| 26 | +3. Add it to your configuration at `dataset.datagouv.organizationIdOrSlug` |
| 27 | +4. Set `dataset.title` in your configuration (this will be used as the dataset title) |
| 28 | + |
| 29 | +The dataset will be automatically created if it doesn't already exist in the organization. |
| 30 | + |
| 31 | +### Option 2: Use an existing dataset |
| 32 | + |
| 33 | +This approach is suitable when you already have a dataset created on data.gouv.fr and want to update it automatically. |
| 34 | + |
| 35 | +1. Create a dataset on [data.gouv.fr](https://www.data.gouv.fr/) (or [demo.data.gouv.fr](https://demo.data.gouv.fr/) for testing) |
| 36 | +2. Copy the dataset ID from the Informations tab on the dataset page (e.g., `6914a64b17a0a61222`) |
| 37 | +3. Add it to your configuration at `dataset.datagouv.datasetId` |
| 38 | + |
| 39 | +## Configure your collection |
| 40 | + |
| 41 | +### 1. Add configuration settings |
| 42 | + |
| 43 | +In your collection's configuration file (e.g., `config/production.json`), add the `datagouv` settings under the `dataset` section: |
| 44 | + |
| 45 | +**For Option 1 (automatic creation):** |
| 46 | + |
| 47 | +```json |
| 48 | +{ |
| 49 | + "dataset": { |
| 50 | + "title": "<collection_name> collection dataset", |
| 51 | + "datagouv": { |
| 52 | + "organizationIdOrSlug": "open-terms-archive" |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +**For Option 2 (existing dataset):** |
| 59 | + |
| 60 | +```json |
| 61 | +{ |
| 62 | + "dataset": { |
| 63 | + "title": "<collection_name> collection dataset", |
| 64 | + "datagouv": { |
| 65 | + "datasetId": "6914a64b17a0a91bb0a61222" |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +### 3. Configure for testing (optional) |
| 72 | + |
| 73 | +If you want to test with the demo environment first, add `useDemo`: |
| 74 | + |
| 75 | +```json |
| 76 | +{ |
| 77 | + "dataset": { |
| 78 | + "title": "<collection_name> collection dataset", |
| 79 | + "datagouv": { |
| 80 | + "organizationIdOrSlug": "open-terms-archive", |
| 81 | + "useDemo": true |
| 82 | + } |
| 83 | + } |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +### 4. Set the API key |
| 88 | + |
| 89 | +Create a `.env` file at the root of your collection repository (if it doesn't already exist) and add your data.gouv.fr API key: |
| 90 | + |
| 91 | +``` |
| 92 | +OTA_ENGINE_DATAGOUV_API_KEY=your_api_key_here |
| 93 | +``` |
| 94 | + |
| 95 | +## Test your configuration |
| 96 | + |
| 97 | +You can test your configuration by manually publishing a dataset: |
| 98 | + |
| 99 | +```bash |
| 100 | +npx ota dataset --publish |
| 101 | +``` |
| 102 | + |
| 103 | +This will create and publish a dataset to data.gouv.fr. Check the output to verify the dataset was published successfully. |
| 104 | + |
| 105 | +## Set up automatic publishing |
| 106 | + |
| 107 | +To automatically publish datasets on a schedule, use the `--schedule` flag: |
| 108 | + |
| 109 | +```bash |
| 110 | +npx ota dataset --schedule --publish --remove-local-copy |
| 111 | +``` |
| 112 | + |
| 113 | +This will publish datasets according to the schedule defined in your configuration (by default, every Monday at 8:30 AM). |
| 114 | + |
| 115 | +## Publishing to multiple platforms |
| 116 | + |
| 117 | +data.gouv.fr publishing can be used alongside GitHub or GitLab releases. Simply configure both platforms and datasets will be published to all configured platforms simultaneously. |
| 118 | + |
| 119 | +See the [configuration reference]({{< relref "collections/reference/configuration#datagouv-fr-publishing" >}}) for all available options. |
0 commit comments