doApiQuery {hubeau}R Documentation

Main internal functions for querying the Hub'Eau API endpoints

Description

The function doQueryApi is called by all the function querying the API endpoints and return the raw data sent by the endpoint.

Usage

doApiQuery(api, endpoint, ..., params)

Arguments

api

a character name of the API (e.g.: "indicateurs_services", "prelevements"...), see example for available APIs

endpoint

a character name of the endpoint, see example for available endpoints in an API

...

parameters of the queries and their values in the format ⁠Param1_Name = "Param1 value", Param2_Name = "Param2 value"⁠, use the function list_params for a list of the available filter parameters for a given API endpoint and see the API documentation for their description

params

(deprecated) a list the list of parameters of the queries and their values in the format list(ParamName = "Param value", ...). This parameter is replaced by the parameter ...

Details

Pagination of the queries is handled automatically and the returned list is the concatenation of all the results sent by the API.

The functions ⁠get_[api]_[endpoint]⁠ call the function doQueryApi and parse the response in a tibble::tibble format for the user (See convert_list_to_tibble).

By default the user agent used for the query is "https://github.com/inrae/hubeau". You can redefined the user agent with the global option "hubeau.user_agent": options(hubeau.user_agent = "My user agent").

Value

A list with the concatenated results returned by the API.

Examples

# To get the available APIs in the package
list_apis()

# To get the available endpoints in an API
list_endpoints("prelevements")

# To get available parameters in endpoint "chroniques" of the API "prelevements"
list_params(api = "prelevements", endpoint = "chroniques")

# To query the endpoint "chroniques" of the API "prelevements"
# on all devices in the commune of Romilly-sur-Seine in 2018
## Not run: 
resp <- doApiQuery(api = "prelevements",
                   endpoint = "chroniques",
                   code_commune_insee = "10323",
                   annee = "2018")
convert_list_to_tibble(resp)

## End(Not run)

[Package hubeau version 0.5.0 Index]