The goal of datagouvfr is to facilitate the extraction of data from the data.gouv.fr website, the French public data platform. This package provides functions to search, retrieve, and process datasets available on the platform.
You can install the development version of datagouvfr like so:
# install.packages("remotes")
install.packages(
'datagouvfr',
repos = c('https://inrae.r-universe.dev', 'https://cloud.r-project.org')
)
First, explore which dataset you want to download on
https://data.gouv.fr, and then copy and paste the last element of the
URL of this dataset (Example: "catalogue-des-donnees-de-data-gouv-fr"
for the URL
https://www.data.gouv.fr/fr/datasets/catalogue-des-donnees-de-data-gouv-fr/).
This will allow you to get the dataset id and then the metadata of the
resources linked to this dataset:
# Load library
library(datagouvfr)
# Get dataset's id
dataset_id <- get_dataset_id("catalogue-des-donnees-de-data-gouv-fr")
dataset_id
#> [1] "5d13a8b6634f41070a43dff3"
# Get metadata
resources_metadata <- get_resources_metadata(dataset_id)
# Print the structure of the first resource metadata
str(resources_metadata[[1]])
#> List of 19
#> $ id : chr "f868cca6-8da1-4369-a78d-47463f19a9a3"
#> $ title : chr "export-dataset-20251206-055027.csv"
#> $ description : NULL
#> $ filetype : chr "file"
#> $ type : chr "main"
#> $ format : chr "csv"
#> $ url : chr "https://static.data.gouv.fr/resources/catalogue-des-donnees-de-data-gouv-fr/20251206-055027/export-dataset-20251206-055027.csv"
#> $ latest : chr "https://www.data.gouv.fr/api/1/datasets/r/f868cca6-8da1-4369-a78d-47463f19a9a3"
#> $ checksum :List of 2
#> ..$ type : chr "sha1"
#> ..$ value: chr "6e40ccc339b79559353b8c3cfc29af8a821b6652"
#> $ filesize : num 2.21e+08
#> $ mime : chr "text/csv"
#> $ created_at : chr "2019-06-26T19:30:07.916000+00:00"
#> $ last_modified: chr "2025-12-06T06:50:37.735000+00:00"
#> $ metrics :List of 1
#> ..$ views: num 3666
#> $ harvest : NULL
#> $ extras :List of 18
#> ..$ csv-export:model : chr "dataset"
#> ..$ check:available : logi TRUE
#> ..$ check:date : chr "2024-10-22T15:25:46.404000"
#> ..$ check:count-availability : num 11
#> ..$ check:status : num 200
#> ..$ check:timeout : logi FALSE
#> ..$ check:headers:content-type : chr "text/csv"
#> ..$ analysis:last-modified-at : chr "2025-12-06T05:50:37+00:00"
#> ..$ analysis:last-modified-detection: chr "last-modified-header"
#> ..$ analysis:content-length : num 2.21e+08
#> ..$ analysis:checksum : chr "6e40ccc339b79559353b8c3cfc29af8a821b6652"
#> ..$ analysis:mime-type : chr "text/plain"
#> ..$ analysis:parsing:finished_at : chr "2025-12-06T06:44:51.941090+00:00"
#> ..$ analysis:parsing:started_at : chr "2025-12-06T06:44:35.248349+00:00"
#> ..$ analysis:parsing:parquet_url : chr "https://object.files.data.gouv.fr/hydra-parquet/hydra-parquet/f868cca6-8da1-4369-a78d-47463f19a9a3.parquet"
#> ..$ analysis:parsing:parquet_size : num 31132620
#> ..$ analysis:parsing:parsing_table : chr "1d9640310df4f2981caef583d31196f2"
#> ..$ analysis:check_id : num 37442448
#> $ preview_url : chr "https://explore.data.gouv.fr/fr/resources/f868cca6-8da1-4369-a78d-47463f19a9a3"
#> $ schema : NULL
#> $ internal :List of 2
#> ..$ created_at_internal : chr "2019-06-26T19:30:07.916000+00:00"
#> ..$ last_modified_internal: chr "2025-12-06T06:50:37.735000+00:00"
# Titles of available resources in this dataset:
sapply(resources_metadata, "[[", "title")
#> [1] "export-dataset-20251206-055027.csv"
#> [2] "export-resource-20251206-055917.csv"
#> [3] "export-dataservice-20251206-060455.csv"
#> [4] "export-reuse-20251206-060453.csv"
#> [5] "export-organization-20251206-060410.csv"
#> [6] "export-harvest-20251206-060459.csv"
#> [7] "export-discussion-20251206-060325.csv"
#> [8] "export-tag-20251206-060458.csv"
Any resource in CSV format can be requested by the function query
which either download the CSV file and filter rows given some conditions
or directly query the tabular API if available (See:
https://www.data.gouv.fr/fr/dataservices/api-tabulaire-data-gouv-fr-beta/).
# Query on data.gouv.fr datasets database
# Find any dataset with the word "cinématographique" in description
datasets_cinema <- query(
resource_metadata = resources_metadata[[1]],
description__contains = "cinématographique"
)
datasets_cinema
#> # A tibble: 29 × 41
#> `__id` id title slug acronym url organization organization_id owner
#> <int> <chr> <chr> <chr> <lgl> <chr> <chr> <chr> <lgl>
#> 1 65199 6350c887… Entr… entr… NA http… Ministère d… 534fff91a3a729… NA
#> 2 66185 6311c164… List… list… NA http… Centre nati… 534fff5fa3a729… NA
#> 3 66694 62ec9633… List… list… NA http… Conseil dép… 582a045088ee38… NA
#> 4 68101 62749db3… Béné… bene… NA http… Région Île-… 534fffa8a3a729… NA
#> 5 68115 62734cc0… Béné… bene… NA http… Région Île-… 534fffa8a3a729… NA
#> 6 68116 62734cb2… Béné… bene… NA http… Région Île-… 534fffa8a3a729… NA
#> 7 68174 626a118e… Ciné… cine… NA http… Région Île-… 534fffa8a3a729… NA
#> 8 79126 5f603d11… Arch… arch… NA http… Département… 544e1b0888ee38… NA
#> 9 89956 5bd89d8e… Etab… etab… NA http… Région Occi… 5a153f5688ee38… NA
#> 10 92445 5af12112… Anné… anne… NA http… Ministère d… 534fff91a3a729… NA
#> # ℹ 19 more rows
#> # ℹ 32 more variables: owner_id <lgl>, description <chr>,
#> # description_short <lgl>, frequency <chr>, license <chr>,
#> # temporal_coverage.start <chr>, temporal_coverage.end <chr>,
#> # spatial.granularity <chr>, spatial.zones <chr>, featured <lgl>,
#> # created_at <chr>, last_modified <chr>, tags <chr>, archived <chr>,
#> # resources_count <int>, main_resources_count <int>, …
# Titles of the first 5 datasets
knitr::kable(datasets_cinema[1:5, c("id", "title", "organization")])
| id | title | organization |
|---|---|---|
| 6350c887ecad6abcaa90f690 | Entreprises : évolution du chiffres d’affaires 2020 des salles de cinémas | Ministère de la Culture |
| 6311c164ebfb165ddc828ded | Liste des visas d’exploitations cinématographiques délivrés de 1945 à 2025 | Centre national du cinéma et de l’image animée |
| 62ec96339bd9110ac90505d1 | Liste des films sortis dans les salles de cinéma en France de 1945 à 2020 (source CNC) | Conseil départemental de la Haute-Garonne - Haute-Garonne Open Data |
| 62749db39faf8888be9ddd2d | Bénéficiaires du fonds de soutien Cinéma international | Région Île-de-France |
| 62734cc07dbd7495fdf11a3b | Bénéficiaires du fonds de soutien Cinéma | Région Île-de-France |