Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
#
@ruedimental

This comment has been minimized.

Copy link

commented Sep 6, 2018

Says:
Error in is.oauth_endpoint(endpoint) || !is.null(credentials) :
object 'token' not found
Why is that?

@gurucollective

This comment has been minimized.

Copy link

commented May 16, 2019

Struggling to get this to work, getting a 403. Is the script up to date?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.