ropensci / weatherOz

An API Client for Australian Weather and Climate Data Resources
https://docs.ropensci.org/weatherOz/
GNU General Public License v3.0
21 stars 7 forks source link

Should api_key take value of some environment variable by default? #79

Open MilesMcBain opened 2 weeks ago

MilesMcBain commented 2 weeks ago

For most API packages I use the API key is set and forget. So once I have set it in my profile the package picks it up from the environment automatically.

Since this package has no default value for api_key I think it means I need to do something like api_key = Sys.getenv("SILO_API_KEY") for every function call, which seems a bit verbose. I also keep forgetting it because my expectations are so heavily shaped by other packages.

Probably the most common example is GITHUB_PAT which is picked up by a few different packages e.g. {remotes}, {pak} et. al. Imagine if we had to do install_github("user/package", api_key = Sys.getenv("GITHUB_PAT")) to install from GitHub! But there are also other precedents I use that call the Mapbox API like {rdeck} and {mapdeck}.

From the looks of things changes to support this would be minimal, and perhaps mostly in documentation of the standard environment variables that are checked. Although, I can see that since it depends on which_api in some cases, things get a little messier. It is possible to have a param default based on the value of another, as I am sure you are aware.

adamhsparks commented 2 weeks ago

I like the idea, @MilesMcBain! I’ll see what I can do