Using and accessing data within a snippet using an API

Hi TB Community,

I am wondering what the general setup would be to access Zillow's API to pull tax data from a specific property

My goal is to: Enter an address into a text box within my snippet and then have the API automatically pull this tax data in the background - and insert it into my snippet

I just requested access to the Zillow API which is apparently approved on a case by case basis- but I also found this inexpensive service that seems to allow access to the Zillow API: https://rapidapi.com/apimaker/api/zillow-com1
(I also found this subpage which seems to be able to give price and tax history)

I am not sure if that service actually offers what I am looking for, but wanted to share it

I guess my questions are:

  1. Is what I'm imagining actually possible?
  2. If yes- what would a snippet look like to pull from that third party API service - or from Zillow's direct API?

I also found this other third party service

Thank you Again

Hello @ajduna7 ,

The urlload command can be used to retrieve data from APIs; for further information, see this link: Text Blaze | {urlload}

An example of how it might work for your case is:

Load data from API: {urlload: https://zillow-com1.p.rapidapi.com/priceAndTaxHistory?zpid=49000475; done=(res) -> ["message": catch(fromJSON(res).message, "???")]; headers=x-rapidapi-host:zillow-com1.p.rapidapi.com, x-rapidapi-key:Your API Key}

The message obtained is {=message}

Make sure to include your API key in x-rapidapi-key in the headers.

Best,
Pratham

Thank you Pratham! - I set it up and entered my API key and it seems to be working - How do I make the API search based on an address entered into a text field within my snippet? Thank you

I did a bit more research and found that the API used for getting tax data functions by entering the ZPID - or Zillow ID -- so a separate API call has to be made by "sending" the address and then of course - getting the ZPID from there and entering it into the URL which requests the tax data

Now the one problem I am running into is that- the URL for the address API call should apparently be formatted like this:
(If sending: "1600 Pennsylvania Ave NW, Washington, DC 20500")

"https://zillow-com1.p.rapidapi.com/propertyExtendedSearch?address=1600+Pennsylvania+Ave+NW&city=Washington&state=DC"

Now I figured I could manually "parse" out an address and enter it into the "URL To Load" - but this would be difficult to standardize - as addresses vary quite often. So I consulted Chat GPT and it suggested that I might enter the Address + City + State as "params" I'm not sure what that means or if it can be designated through form variables in a Snippet?

I tried to create this snippet in the meantime to "parse" down a sample address to the right pieces to be able to enter it as a standardized address- but as you can see- it inserts the errors when there is not a "position" at that part of the list -- and this is important, because sometimes a City could be one word: "Cleveland" or two words: "Shaker Heights" and a full street address could be: 3140 W 68th St (which has 4 "pieces") or "11919 Martin Luther King Jr Dr" (which has 6 "pieces")

{formtext: default=3140 W 68th St, Cleveland, OH 44102\ ; cols=50; name=evaladdress}

https://zillow-com1.p.rapidapi.com/propertyExtendedSearch?address={=address1}{=address2insert}{=address3insert}{=address4insert}{=address5insert}{=address6insert}&city={=city1}{=city2insert}{=city3insert}{=city4insert}&state=OH

{streetaddress=split(evaladdress, ",")[1]}
{=streetaddress}
{address1=split(streetaddress, " ")[1]}
{=address1}
{address2=split(streetaddress, " ")[2]}
{=address2}{address2insert=concat("+",address2) if address2<>"" else ""}
{address3=split(streetaddress, " ")[3]}
{=address3}{address3insert=concat("+",address3) if address3<>"" else ""}
{address4=split(streetaddress, " ")[4]}
{=address4}{address4insert=concat("+",address4) if address4<>"" else ""}
{address5=split(streetaddress, " ")[5]}
{=address5}{address5insert=concat("+",address5) if address5<>"" else ""}
{address6=split(streetaddress, " ")[6]}
{=address6}{address6insert=concat("+",address6) if address6<>"" else ""}

{city=split(evaladdress, ",")[2]}
{=city}
{city1=split(city, " ")[1]}
{=city1}{city1insert=concat("+",city1) if city1<>"" else ""}
{city2=split(city, " ")[2]}
{=city2}{city2insert=concat("+",city2) if city2<>"" else ""}
{city3=split(city, " ")[3]}
{=city3}{city3insert=concat("+",city3) if city3<>"" else ""}
{city4=split(city, " ")[4]}
{=city4}{city4insert=concat("+",city4) if city4<>"" else ""}

{State="OH"}
{=state}

Hey @ajduna7

You can use the catch() function to handle the error cases. An expression like: {city4=catch(split(city, " ")[4], "")} should work.

Yes we can integrate params in the urlload command in a Text Blaze snippet. They can be added as part of the url itself, like so:

{params=["address": "1600", "city": "Washington", "state": "DC"]}

{urlload: https://blaze.today/?{=join(map(keys(params), param_key -> param_key & "=" & params[param_key]), "&")}}
1 Like

Thank you Gaurang!! I used the catch function and it allows me to enter the address correctly into the URL