Searches the platform's themes via the v2 topics/search endpoint and
returns a tibble with one row per matching topic, including its stable
24-hex id. That id is what you pass to the topic argument of
dg_find_datasets() to restrict a catalog search to one theme. (data.gouv
does not resolve topic names/slugs to ids inside dg_find_datasets(), so
this finder is the way to discover a theme and get its id.)
Arguments
- q
Optional full-text query matched against topic names/descriptions (server-side). Defaults to
NULL, meaning no filter.- n
Maximum number of topics to return. Defaults to
20. Set toInfto retrieve as many as the API allows.- elements
Whether to fetch each topic's
elementssubsection (one extra request per topic, an N+1 crawl) to fill then_datasets,n_dataservicesandn_reusescounts exactly. Defaults toFALSE, in which casen_elementsis the topic's declared total and the breakdown counts areNA.
Value
A tibble::tibble() with one row per matching topic and columns:
id— the stable, unique 24-hex topic id (passable to thetopicargument ofdg_find_datasets()). Always non-NA.name— the topic's display name.slug— the URL-friendly slug.description— the topic's description.tags— comma-joined tags, orNA.featured— whether the platform features this topic.n_elements— number of elements (datasets, reuses, dataservices, ...) grouped under the topic, from the API.n_datasets,n_dataservices,n_reuses— per-kind counts, only whenelements = TRUE(elseNA).
Details
Useful when you want to discover which curated themes exist and how many elements (datasets, reuses, dataservices...) they group, before narrowing a search — e.g. browse "Mobilité", "Environnement", "Énergie".
Examples
if (FALSE) { # interactive()
# Browse the curated themes.
dg_find_topics(n = 5)[, c("id", "name", "n_elements")]
# Narrow a catalog search to one theme once you have its id.
mob <- dg_find_topics(q = "mobilité")
dg_find_datasets(topic = mob$id[1], n = 10)
}