Skip to content

Commit

Permalink
Merge pull request #196 from daniel-simeone/set_api_key---set_cancens…
Browse files Browse the repository at this point in the history
…us_api_key

change error messages and vignette to refer to  renamed set_cancensus_api_key
  • Loading branch information
mountainMath authored Mar 3, 2023
2 parents a39c509 + 409892a commit 4979e91
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/cancensus.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ get_census <- function (dataset, regions, level=NA, vectors=c(), geo_format = NA
meta_file <- paste0(data_file, ".meta")
if (!use_cache || !file.exists(data_file)) {
if (!have_api_key) {
stop(paste("No API key set. Use set_api_key('<your API ket>`) to set one, or set_api_key('<your API ket>`, install = TRUE) to save is permanently in our .Renviron."))
stop(paste("No API key set. Use set_cancensus_api_key('<your API ket>`) to set one, or set_cancensus_api_key('<your API ket>`, install = TRUE) to save is permanently in our .Renviron."))
}
url <- paste0(base_url, "data.csv")
response <- if (!quiet) {
Expand Down Expand Up @@ -206,7 +206,7 @@ get_census <- function (dataset, regions, level=NA, vectors=c(), geo_format = NA
meta_file <- paste0(geo_file, ".meta")
if (!use_cache || !file.exists(geo_file)) {
if (!have_api_key) {
stop(paste("No API key set. Use set_api_key('<your API ket>`) to set one, or set_api_key('<your API ket>`, install = TRUE) to save is permanently in our .Renviron."))
stop(paste("No API key set. Use set_cancensus_api_key('<your API ket>`) to set one, or set_cancensus_api_key('<your API ket>`, install = TRUE) to save is permanently in our .Renviron."))
}
url <- paste0(base_url, "geo.geojson")
response <- if (!quiet) {
Expand Down
2 changes: 1 addition & 1 deletion R/intersect_geometry.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ get_intersecting_geometries <- function(dataset, level, geometry, simplified = F

if (!use_cache || !file.exists(data_file)) {
if (!have_api_key) {
stop(paste("No API key set. Use set_api_key('<your API ket>`) to set one, or set_api_key('<your API ket>`, install = TRUE) to save is permanently in our .Renviron."))
stop(paste("No API key set. Use set_cancensus_api_key('<your API ket>`) to set one, or set_cancensus_api_key('<your API ket>`, install = TRUE) to save is permanently in our .Renviron."))
}
url <- paste0(cancensus_base_url(),"/api/v1/intersecting_geographies")
body <- list(dataset=dataset,
Expand Down
2 changes: 1 addition & 1 deletion vignettes/cancensus.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ As Statistics Canada does not provide direct API access to Census data, **cancen

**cancensus** requires a valid CensusMapper API key to use. You can obtain a free API key by [signing up](https://censusmapper.ca/users/sign_up) for a CensusMapper account. CensusMapper API keys are free and public API quotas are generous; however, due to incremental costs of serving large quantities of data, there limits to API usage in place. For most use cases, these API limits should not be an issue. Production uses with large extracts of fine grained geographies may run into API quota limits. For larger quotas, please get in touch with Jens [directly](mailto:[email protected]).

To check your API key, just go to "Edit Profile" (in the top-right of the CensusMapper menu bar). Once you have your key, you can store it in your system environment so it is automatically used in API calls. To do so just enter `set_api_key(<your_api_key>, install = TRUE)`
To check your API key, just go to "Edit Profile" (in the top-right of the CensusMapper menu bar). Once you have your key, you can store it in your system environment so it is automatically used in API calls. To do so just enter `set_cancensus_api_key(<your_api_key>, install = TRUE)`

## Installing cancensus

Expand Down

0 comments on commit 4979e91

Please sign in to comment.