Skip to content

Instantly share code, notes, and snippets.

@henningsway
Forked from patperu/GET_Immoscout24.R
Created March 16, 2019 01:02
Show Gist options
  • Save henningsway/107a65055e232f8de3257f18de2f3c77 to your computer and use it in GitHub Desktop.
Save henningsway/107a65055e232f8de3257f18de2f3c77 to your computer and use it in GitHub Desktop.
Receive data from the ImmobilienScout24-API
library('httr')
library('jsonlite')
options(httr_oauth_cache = TRUE)
options(scipen=999)
# Keys, but it's better to set up
# environment variables via 'Sys.setenv'
consumerKey <- 'aaa'
consumerSecret <- 'bbb'
tokenGenerated <- 'ccc'
tokenSecret <- 'ddd'
# Apartments in Berlin
url <- "http://rest.immobilienscout24.de/restapi/api/search/v1.0/search/region?realestatetype=apartmentrent&geocodes=1276003001"
app <- oauth_app("app", key = consumerKey, secret = consumerSecret)
# Thanks Hadley!!
httr::Token1.0$new(
endpoint = NULL,
app = app,
credentials = list(
oauth_token = token,
oauth_token_secret = token_secret)) -> immo24_token
res <- httr::GET(url, httr::config(token = immo24_token))
stop_for_status(res)
x <- fromJSON(rawToChar(res$content))$resultlist.resultlist$resultlistEntries$resultlistEntry
x <- x[[1]]$resultlist.realEstate
x
# str(x, 1)
#'data.frame': 20 obs. of 21 variables:
# $ @xsi.type : chr "search:ApartmentRent" "search:ApartmentRent" "search:ApartmentRent" "search:ApartmentRent" ...
# $ @id : chr "87092527" "86704027" "87400507" "86178612" ...
# $ title : chr "Erstbezug im Neubau! Besichtigung: Mo., Mi., Fr. jeweils von 16-17 Uhr" "Top Sanierte ...."
# $ address :'data.frame': 20 obs. of 7 variables:
# $ companyWideCustomerId : chr "001.559854" "001.1633040" "001.396445" "001.263131" ...
# $ titlePicture :'data.frame': 20 obs. of 8 variables:
# $ floorplan : chr "true" "false" "false" "false" ...
# $ streamingVideo : chr "false" "false" "false" "true" ...
# $ listingType : chr "XL" "XL" "XL" "XL" ...
# $ showcasePlacementColor : chr "#E74914" "#343434" "#343434" "#343434" ...
# $ privateOffer : chr "false" "false" "false" "false" ...
# $ realtorLogo : chr "http://pictureis24-a.akamaihd.net/pic/orig03/N/151/xxxxxxxx.jpg"........
# $ realtorLogoForResultList :'data.frame': 20 obs. of 5 variables:
# $ price :'data.frame': 20 obs. of 4 variables:
# $ livingSpace : num 76.8 83 74.5 221 98 ...
# $ numberOfRooms : int 3 3 3 6 4 1 4 4 2 3 ...
# $ energyPerformanceCertificate: chr "true" "true" "true" NA ...
# $ builtInKitchen : chr "false" "false" "true" "false" ...
# $ balcony : chr "true" "false" "true" "true" ...
# $ garden : chr "false" "false" "false" "true" ...
# $ calculatedPrice :'data.frame': 20 obs. of 5 variables:
#
# FINI
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment