-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#' Postcode Properties | ||
#' | ||
#' @import dplyr | ||
#' @import httr | ||
#' @import XML | ||
#' | ||
#' @param postcode A string representing a valid UK postcode, e.g. "EH1 2NG". | ||
#' @param API_key An API key from Zoopla. | ||
#' | ||
#' @return A list. | ||
#' @export | ||
#' | ||
#' @references \url{https://developer.zoopla.co.uk/docs/read/Arrange_Appraisals} | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' | ||
#' postcode_properties("EH12NG", "YOUR_API_KEY") | ||
#' postcode_properties("EH1 2NG", "YOUR_API_KEY") | ||
#' } | ||
#' | ||
postcode_properties <- function(postcode=NULL, API_key=NULL){ | ||
if (!is.character(postcode) || nchar(postcode) < 2) { | ||
stop("Please provide a valid UK outcode.") | ||
} | ||
if (!is.character(API_key)) { | ||
stop("Please provide an API key.") | ||
} | ||
postcode <- gsub(" ", "", postcode, fixed = TRUE) | ||
r <- GET("https://api.zoopla.co.uk/api/v1/postcode_properties", | ||
query = list(postcode = postcode, api_key = API_key)) | ||
warn_for_status(r) | ||
r %>% content(encoding="UTF-8") %>% xmlParse() %>% xmlToList() %>% return() | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.