get_servingsize: get_servingsize

View source: R/endpoints.R

get_servingsizeR Documentation

get_servingsize

Description

Makes a query to the Canadian Nutrient File servingsize endpoint. This endpoint returns a list of serving sizes as well as the corresponding food code and description. The conversion factor value is also given. This represents the proportion of weight between cooked edible portion and raw edible portion. conversion factor

Usage

get_servingsize(apiKey = NULL, foodCode = NULL, lang = "en")

Arguments

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, the system environment variables will be checked.

foodCode

The code indicating the food you want to search for. If null, all foods and their corresponding serving sizes are returned.

lang

The language to return results in, can be either 'en' or 'fr'.

Value

A tibble containing conversion factor values, food names, food codes and serving sizes.

Examples

## Not run: 
get_servingsize()
get_servingsize(foodCode = 45)
get_servingsize(foodCode = 45, lang = "fr")
## End(Not run)

nutrientr documentation built on March 18, 2022, 6:27 p.m.