query_api | R Documentation |
query_api Makes a query to the Canadian Nutrient Files API.
query_api(path, apiKey = NULL, id = NULL, lang = "en")
path |
the path to the desired endpoint. (Should be one of food, nutrientamount nutrientgroup, nutrientname, nutrientsource, refuseamount, servingsize, or yieldamount.) |
apiKey |
key to access the API. Can be retrieved from https://hc-sc.api.canada.ca/en/detail?api=cnf#!/Nutrient/get_nutrientamount.
If none is provided, @seealso |
id |
the id of what you're looking for. Meaning of the id changes depending on endpoint. |
lang |
the language you are using and want results returned in. |
a structure with the parsed text response, the raw response, the endpoint path, and the id.
Note that this function is based on, and repeats much of the code in the R API package best practices, available at https://httr.r-lib.org/articles/api-packages.html#overall-design-1.
## Not run: query_api("food") query_api("food", id = 2314) query_api("nutrientgroup", id = 1) query_api("nutrientname", id = 1) query_api("nutrientsource", id = 82) query_api("refuseamount", id = 2314) query_api("servingsize", id = 2314) query_api("yieldamount", id = 2314) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.