Search code examples
rapizillow

How to use the zillow api with ZillowR


I want to access the GetDeepSearchResults info from the Zillow API.

My code:

library(ZillowR)
zapi_key = getOption('Myapikey')
GetDeepSearchResults(
    address = '600 S. Quail Ct.',
    zipcode = '67114',
    rentzestimate = FALSE,
    api_key = zapi_key
)

Error:

Error in GetDeepSearchResults(address = "600 S. Quail Ct.", zipcode = "67114",  : 
  unused arguments (zipcode = "67114", api_key = zapi_key)

Why does this error occur? What can I do to fix this?


Edit: I changed the code according to the comments and got this:

My code:

library(ZillowR)
zapi_key = getOption('myapikey')
GetDeepSearchResults(
    address = '600 S. Quail Ct.',
    citystatezip = '67114',
    rentzestimate = FALSE,
    zws_id = 'myapikey',
    url = "http://www.zillow.com/webservice/GetDeepSearchResults.htm"
)

Output:

$request
$request$address
NULL

$request$citystatezip
NULL

$message
$message$text
[1] "Error: invalid or missing ZWSID parameter"

$message$code
[1] "2"

$response
NULL

How can I fix this?


Solution

  • The unused arguments error is typical when you pass arguments, which are not parts of the function. So R doesn't know what to do with those and returns the error. You can check the documentation of the function with ?GetDeepSearchResults

    This shows you the usage:

    GetDeepSearchResults(address = NULL, citystatezip = NULL,
      rentzestimate = FALSE, zws_id = getOption("ZillowR-zws_id"),
      url = "http://www.zillow.com/webservice/GetDeepSearchResults.htm")
    

    To have this work, you have to set your id first with (you can create an id on https://www.zillow.com/howto/api/APIOverview.htm):

    set_zillow_web_service_id("youractualkey")
    

    So you function does not have the argument zipcode and api_key. Let's change your arguments to some which exist:

        GetDeepSearchResults(address='600 S. Quail Ct.', citystatezip ='67114',
                             rentzestimate=FALSE)
    

    You surely recognized I did not use your api_key. This is because the default:zws_id = getOption("ZillowR-zws_id") calls your global 'ZillowR-zws_id' which you just set with the set_zillow_web_service_id() command. So it's not necessary to change the default value. But you can skip this when you use zws_id ="youractualkey" from zillow

    I made a random account I set up for validating. This gives me the output:

    $request
    $request$address
    NULL
    
    $request$citystatezip
    NULL
    
    
    $message
    $message$text
    [1] "Error: this account is not authorized to execute this API call"
    
    $message$code
    [1] "6"
    
    
    $response
    NULL
    

    So I could successfully contact the server and my key was recognized. The account authority is not R related and has to be set on the website.