Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/erykwalczak/zooplar

R API wrapper for Zoopla
https://github.com/erykwalczak/zooplar

api-wrapper proptech r realestate zoopla zoopla-api

Last synced: about 1 month ago
JSON representation

R API wrapper for Zoopla

Awesome Lists containing this project

README

        

---
title: "zooplaR"
output: github_document
---

```{r, echo = FALSE}
NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true")
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-",
purl = NOT_CRAN
)
```

[![Travis-CI Build Status](https://travis-ci.org/erzk/zooplaR.svg?branch=master)](https://travis-ci.org/erzk/zooplaR)
[![Coverage Status](https://img.shields.io/codecov/c/github/erzk/zooplaR/master.svg)](https://codecov.io/github/erzk/zooplaR?branch=master)
[![Package-License](http://img.shields.io/badge/license-GPL--3-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-3.0.html)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/PostcodesioR)](https://cran.r-project.org/package=PostcodesioR)

### About

This package is an API wrapper for accessing the UK housing market data from [Zoopla](http://www.zoopla.co.uk/).
Check the package's [website](https://erzk.github.io/zooplaR/) for more examples.

### Installation

* Install *devtools* if you don't have it yet: `install.packages("devtools")`
* Use `devtools::install_github("erzk/zooplaR")` to install the package.

* Read the zooplaR's [vignette](https://github.com/erzk/zooplaR/blob/master/vignettes/Introduction_to_zooplaR.Rmd).

* [Register](http://developer.zoopla.com/member/register/) for an account and an API key.

* Store the key in an environment variable.

```{r, eval = FALSE}
file.edit("~/.Renviron")
```

Then create a variable in the `.Renviron` file like this:

```{r, eval = FALSE}
zoopla_key <- "YOUR_KEY_GOES_HERE"
```

For other options of storing a key, read this [vignette](https://cran.r-project.org/web/packages/httr/vignettes/secrets.html).

In my case, the API key is stored in the variable `zoopla_key`. You can check whether it's defined and loaded correctly and save it to a variable using:

```{r}
zoopla_key <- Sys.getenv("zoopla_key")
```

The functions in this package assume that the API key is stored in the system environment as a `zoopla_key` variable. If not, then most function calls will fail.

### Usage

Load the package

```{r}
library(zooplaR)
```

## Get the session id

This will be useful for other calls

```{r}
get_session_id(zoopla_key)
```

## Get the average property prices

Focus on a particular outcode:

```{r}
aasp <- average_area_sold_price("EH1 2NG", "outcode", zoopla_key)

# overview
str(aasp)
```

Or another use another function to focus on individual streets:

```{r}
asp <- average_sold_prices("EH1 2NG", "outcode", "streets", zoopla_key)

# overview
str(asp)
```

In the example above, the streets can be found in the URLs, e.g.

```{r}
asp[2]$areas$prices_url
```

## Zed indices

Zoopla prepared its own indices, they can be accessed with the following functions:

```{r}
zi <- zed_index("E151AZ", "town", zoopla_key)

# overview
str(zi)
```

Function `zed_index()` can also provide indices on other aggregation levels. Please consult documentation for more info.

There is also another zed index function that takes more arguments:

```{r}
azi <- area_zed_indices("sw185rw", "postcodes", "outcode", 1, 10, zoopla_key, "descending")

# overview
str(azi)
```

## Property listings

You can get the Zoopla listings for a particular area using the following call:

```{r}
listings <- property_listings(postcode = "E15 4QS", API_key = zoopla_key)

# overview
names(listings)

str(listings[6])
```

## Get house price charts

Chart showing prices in the last three months in a particular outcode:

```{r}
avgr <- area_value_graphs("W12", zoopla_key)

# overview
str(avgr)

# to see a chart, follow the URLs, e.g.
avgr$average_values_graph_url
```

More detailed charts can also include information about council tax, crime, education, or population age range. These charts can be generated by Zoopla using the following also on an incode level.

```{r}
ligr <- local_info_graphs("W12", zoopla_key)

# overview
str(ligr)

# to see a chart, follow the URLs, e.g.
ligr$council_tax_graph_url
```

## Suggest autocompletions for locations

If you are not sure how to spell a location, you can use the API to get suggestions. On this example I made a typo when writing Ruislip:

```{r}
geo_ac <- geo_autocomplete("ruisli", "listings", zoopla_key)

# overview
str(geo_ac)
```

### Limitations

As most APIs, Zoopla [limits](http://developer.zoopla.com/API_terms_of_use) the number of calls. The limit is 100 calls per second and 100 per hour. Once you hit the limit, the 403 error will appear.

### Thanks

![](https://www.zoopla.co.uk/static/images/mashery/powered-by-zoopla-150x73.png)