To you need geocoded rental data for German cities? This small R script helps

The following short R script uses the Json parser Jsonlite and fetches gecoded real estate offers via the Nestoria REST API. The Nestoria API does not require any kind of authentification (as OAuth or an API key) and delivers current real estate date from all big and also smaller German real estate portals. Downloads are limited to 20 or 50 data points per page and to 1000 offers per request. So if you need a larger area, just adapt the bounding box or by filtering using the request paramaters documented on the Nestoria developers website: http://www.nestoria.co.uk/help/api-search-listings
The script loops through the pages provided by the API and puts the result into a R dataframe. The R dataframe easily can be exported as CSV for further use in QGIS or any other GIS software (e.g. Arc GIS).
If you have any questions, feel free to ask. The comments in the script are partly German and partly English, sorry for that mess :-). I tested the script fetching Berlin and Potsdam real estate data.

 


#Author Harald Schernthanner, basierend auf: JSOn Data über API mit meheren Pages: https://cran.r-project.org/web/packages/jsonlite/vignettes/json-paging.html
#Schleife zum fetchen der Daten

install.packages("jsonlite")
install.packages('curl')
library(jsonlite)
  
baseurl <- "http://api.nestoria.de/api?country=de&pretty=1&encoding=json&action=search_listings&place_name=Potsdam&listing_type=rent"
#Anzahl der "Seiten entscheidet wie oft durch den Datensatz geloopt werden soll
#eine for Schleife loopt durch die Seiten und schreibt die Ergebnisse in den Dataframe "pages"

pages <- list()
for(i in 0:24){
  mydata <- fromJSON(paste0(baseurl, "&page=", i))
  message("Retrieving page ", i)
  pages[[i+1]] <- mydata$response$listings
}

#Kombiniert die einzelnen Abfragen
angebote_potsdam <- rbind.pages(pages)

#check output
nrow(angebote_potsdam)


#Exportieren der Daten

write.csv2(angebote_potsdam, "potsdam.csv")



Housing prices with service costs in Potsdam inner city
Housing prices with service costs in Potsdam inner city

Kommentar hinterlassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.