doApiQuery.Rd 2.48 KiB
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/doApiQuery.R, R/get_available_params.R
\name{doApiQuery}
\alias{doApiQuery}
\alias{get_available_params}
\title{Main internal functions for querying the Hub'eau APIs}
\usage{
doApiQuery(
  api,
  operation,
  params,
  cfg = config::get(file = system.file("config.yml", package = "hubeau"))
get_available_params(
  api,
  operation,
  cfg = config::get(file = system.file("config.yml", package = "hubeau"))
\arguments{
\item{api}{a \link{character} name of the API (e.g.: "indicateurs_services", "prelevements"...), see example for available APIs}
\item{operation}{a \link{character} name of the endpoint, see example for available endpoints in an API}
\item{params}{a \link{list} the list of parameters of the queries and their values in the format \code{list(ParamName = "Param value", ...)}, use the function \link{get_available_params} for a list of the available filter parameters for a given operation in an API and see the API documentation for their description}
\item{cfg}{a \link{config} object describing the configuration of the APIs. Use the internal package configuration by default
configuration}
\value{
A \link{list} with the concatenated results returned by the API.
\description{
The function \code{doQueryApi} is called by all the function querying the APIs and return the raw data sent by the API.
Pagination of the queries is handled automatically and the returned \link{list} is the concatenation of all the results sent by the API.
\details{
The function \code{get_available_params} returns the list of available query parameters for a given operation in an API.
The functions \verb{get_[api]_[operation]} call the function \code{doQueryApi} and convert the response in a convenient format for the user (\link{data.frame} or \link[tibble:tibble]{tibble::tibble})
\examples{
# To get the available APIs in the package
cfg <- config::get(file = system.file("config.yml", package = "hubeau"))
names(cfg$apis)
# To get the available operation in an API
names(cfg$apis[["prelevements"]]$operations)
# To get available parameters in operation "chroniques" of the API "prelevements"
get_available_params(api = "prelevements", operation = "chroniques")
# To query the operation "chroniques" of the API "prelevements"
# on all devices in the commune of Romilly-sur-Seine in 2018
doApiQuery(api = "prelevements",
           operation = "chroniques",
           params = list(code_commune_insee = "10323", annee = "2018"))