Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
erzk committed May 22, 2017
1 parent 0340fdd commit 80f0e78
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
34 changes: 34 additions & 0 deletions R/postcode_properties.R
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()
}
30 changes: 30 additions & 0 deletions man/postcode_properties.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 80f0e78

Please sign in to comment.