Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need hipaa compliant geocodio endpoint #137

Closed
groliver-pcci opened this issue Sep 20, 2021 · 9 comments
Closed

need hipaa compliant geocodio endpoint #137

groliver-pcci opened this issue Sep 20, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@groliver-pcci
Copy link

geocodio service has a separate hipaa compliant endpoint, access is restricted to this address only.

Can future release add a geocodio-hipaa, flag or api-url alias
in
api_url
"geocodio" = get_geocodio_url(geocodio_v, reverse = reverse , hipaa= F),

or

get_geocodio_hipaa_url <- function(api_v ='1.6', reverse = FALSE) {

return API URL based on api version (ex. 1.6)

url_keyword <- if (reverse == TRUE) 'reverse' else 'geocode'
return(paste0("https://api-hipaa.geocod.io/v", as.character(api_v), "/", url_keyword))
}

@groliver-pcci groliver-pcci added the bug Something isn't working label Sep 20, 2021
@jessecambon
Copy link
Owner

jessecambon commented Sep 20, 2021

Hi @groliver-pcci, yes we could add a geocodio_hipaa = TRUE/FALSE parameter. Just to make sure, you are currently able to use the HIPAA endpoint with api_url = https://api-hipaa.geocod.io/v1.6/geocode and api_url = https://api-hipaa.geocod.io/v1.6/reverse, correct?

@groliver-pcci
Copy link
Author

groliver-pcci commented Sep 20, 2021 via email

@jessecambon
Copy link
Owner

Sounds good, I'll let you know when I have a branch ready for you to test.

However, I'm not sure I'm following the issue you are running into. You should be able to just use the api_url parameter to specify the HIPAA endpoint without modifying the current tidygeocoder package code. If this isn't working, could you post a reprex? https://reprex.tidyverse.org/

@groliver-pcci
Copy link
Author

groliver-pcci commented Sep 20, 2021 via email

@jessecambon
Copy link
Owner

jessecambon commented Sep 20, 2021

I see, I typically click the Install and Restart button in the "Build" panel of RStudio to load new code changes I've made on the package. That might be the step you're missing (for loading the rm_quote function, etc.).

In any case, I have a branch ready for you to try. You can install it with this command:

devtools::install_github("jessecambon/tidygeocoder", ref = "geocodio-hipaa")

After that installs you should be able to use the geocodio_hipaa argument like this:

library(tidygeocoder)
results <- geo(address = "Toronto", method = 'geocodio', geocodio_hipaa = TRUE, verbose = TRUE)

Let me know if you run into any issues.

@groliver-pcci
Copy link
Author

groliver-pcci commented Sep 22, 2021 via email

@jessecambon jessecambon added enhancement New feature or request and removed bug Something isn't working labels Sep 28, 2021
@dpprdan
Copy link
Contributor

dpprdan commented Sep 29, 2021

Since it is possible to query the HIPAA geocod.io API with the api_url parameter, I am wondering whether an additional parameter is really necessary. One could use purrr::partial to save some typing in case geo() is called more than once in a script.

library(tidygeocoder)
library(purrr)

address <- "600 Peachtree Street NE, Atlanta, GA"

# Query to the main geocod.io API
geo(address, method = "geocodio", verbose = TRUE)
#> Number of Unique Addresses: 1
#> Querying API URL: https://api.geocod.io/v1.6/geocode
#> Passing the following parameters to the API:
#> q : "600 Peachtree Street NE, Atlanta, GA"
#> api_key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> limit : "1"
#> HTTP Status Code: 200
#> Query completed in: 1 seconds
#> 
#> # A tibble: 1 x 3
#>   address                                lat  long
#>   <chr>                                <dbl> <dbl>
#> 1 600 Peachtree Street NE, Atlanta, GA  33.8 -84.4
# use purrr:partial to build a custom geo() function. 
hipaa_geo <- partial(geo, method = "geocodio", api_url = "https://api-hipaa.geocod.io/v1.6/geocode")

# hipaa_geo() works just like geo(method = "geocodio", api_url = "https://api-hipaa.geocod.io/v1.6/geocode") would
# The query fails here, because I don't have a key for the HIPAA geocod.io API, 
# which is different from the main geocod.io key
hipaa_geo(address, verbose = TRUE)
#> Number of Unique Addresses: 1
#> Querying API URL: https://api-hipaa.geocod.io/v1.6/geocode
#> Passing the following parameters to the API:
#> q : "600 Peachtree Street NE, Atlanta, GA"
#> api_key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> limit : "1"
#> Warning in query_api(api_url, api_query_parameters, method = method): Forbidden
#> (HTTP 403).
#> HTTP Status Code: 403
#> Error: Invalid API key
#> Query completed in: 0.5 seconds
#> 
#> # A tibble: 1 x 3
#>   address                                lat  long
#>   <chr>                                <dbl> <dbl>
#> 1 600 Peachtree Street NE, Atlanta, GA    NA    NA

Maybe we should advertise the purrr::partial approach a bit for this use-case.

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.1.1 (2021-08-10)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language en                          
#>  collate  German_Germany.1252         
#>  ctype    German_Germany.1252         
#>  tz       Europe/Berlin               
#>  date     2021-09-29                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version date       lib source            
#>  assertthat     0.2.1   2019-03-21 [1] standard (@0.2.1) 
#>  backports      1.2.1   2020-12-09 [1] standard (@1.2.1) 
#>  cli            3.0.1   2021-07-17 [1] standard (@3.0.1) 
#>  crayon         1.4.1   2021-02-08 [1] standard (@1.4.1) 
#>  curl           4.3.2   2021-06-23 [1] standard (@4.3.2) 
#>  DBI            1.1.1   2021-01-15 [1] standard (@1.1.1) 
#>  digest         0.6.27  2020-10-24 [1] standard (@0.6.27)
#>  dplyr          1.0.7   2021-06-18 [1] standard (@1.0.7) 
#>  ellipsis       0.3.2   2021-04-29 [1] standard (@0.3.2) 
#>  evaluate       0.14    2019-05-28 [1] standard (@0.14)  
#>  fansi          0.5.0   2021-05-25 [1] standard (@0.5.0) 
#>  fastmap        1.1.0   2021-01-25 [1] standard (@1.1.0) 
#>  fs             1.5.0   2020-07-31 [1] standard (@1.5.0) 
#>  generics       0.1.0   2020-10-31 [1] standard (@0.1.0) 
#>  glue           1.4.2   2020-08-27 [1] standard (@1.4.2) 
#>  highr          0.9     2021-04-16 [1] standard (@0.9)   
#>  htmltools      0.5.2   2021-08-25 [1] CRAN (R 4.1.1)    
#>  httr           1.4.2   2020-07-20 [1] standard (@1.4.2) 
#>  jsonlite       1.7.2   2020-12-09 [1] standard (@1.7.2) 
#>  knitr          1.34    2021-09-09 [1] standard (@1.34)  
#>  lifecycle      1.0.0   2021-02-15 [1] standard (@1.0.0) 
#>  magrittr       2.0.1   2020-11-17 [1] standard (@2.0.1) 
#>  pillar         1.6.2   2021-07-29 [1] standard (@1.6.2) 
#>  pkgconfig      2.0.3   2019-09-22 [1] standard (@2.0.3) 
#>  purrr        * 0.3.4   2020-04-17 [1] standard (@0.3.4) 
#>  R6             2.5.1   2021-08-19 [1] standard (@2.5.1) 
#>  reprex         2.0.1   2021-08-05 [1] standard (@2.0.1) 
#>  rlang          0.4.11  2021-04-30 [1] standard (@0.4.11)
#>  rmarkdown      2.11    2021-09-14 [1] standard (@2.11)  
#>  rstudioapi     0.13    2020-11-12 [1] standard (@0.13)  
#>  sessioninfo    1.1.1   2018-11-05 [1] standard (@1.1.1) 
#>  stringi        1.7.4   2021-08-25 [1] CRAN (R 4.1.1)    
#>  stringr        1.4.0   2019-02-10 [1] standard (@1.4.0) 
#>  styler         1.6.1   2021-09-17 [1] standard (@1.6.1) 
#>  tibble         3.1.4   2021-08-25 [1] standard (@3.1.4) 
#>  tidygeocoder * 1.0.3   2021-04-19 [1] standard (@1.0.3) 
#>  tidyselect     1.1.1   2021-04-30 [1] standard (@1.1.1) 
#>  utf8           1.2.2   2021-07-24 [1] standard (@1.2.2) 
#>  vctrs          0.3.8   2021-04-29 [1] standard (@0.3.8) 
#>  withr          2.4.2   2021-04-18 [1] standard (@2.4.2) 
#>  xfun           0.26    2021-09-14 [1] standard (@0.26)  
#>  yaml           2.2.1   2020-02-01 [1] standard (@2.2.1) 
#> 
#> [1] C:/Users/Daniel.AK-HAMBURG/Documents/R/win-library/4.1
#> [2] C:/Program Files/R/R-4.1.1/library

@jessecambon
Copy link
Owner

jessecambon commented Sep 30, 2021

@dpprdan that's a nice approach for customizing the API endpoint that we could offer.

In geo() we already have a number of parameters that are there to facilitate changing the API endpoint: geocodio_v (Geocodio API version number), mapbox_permanent, iq_region, return_type (for US Census), and mapquest_open. One solution could be to wrap all of these parameters into a single named list parameter api_options. For instance:

geo(address = 'Seoul', method = 'geocodio', api_options = list(geocodio_v = 1.6, geocodio_hipaa = TRUE))

This would allow us to accommodate some API endpoint customization shortcuts while reducing the number of parameters in geo() (and reverse_geo()). For additional API endpoint customization that we aren't offering a shortcut for, we could offer your purrr::partial approach.

@jessecambon
Copy link
Owner

The api_options parameter described above is now implemented in the development version (main branch). See the geo function documentation for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants