When Drew told me of GeekEstate, I was told I could blog about anything geeky & real estate related. He said I could even blog about the Trulia API, if I wanted to. So I decided to take him up on the offer.

In the spirit of surprises, I decided not only to write a Trulia API blog post tutorial (on a blog founded by Zillow). But, to make it more surprising, I decided to write it in PHP (if you follow my writings on Rain City Guide, you should know I have a strong preference for ASP.net).

Since I’m new to PHP (but pretty familiar with web programming concepts), I decided to purchase a good PHP refernce book, download a good PHP IDE, roll up my sleeves and get to work. If the rest of this post is off the deep end, don’t worry about it. PHP web service programming is what I would call an advanced topic. And if you are a professional PHP programmer, be gentle, I’m a PHP virgin. Anyway, since most of us are new to PHP programming, I decided that writing an API demo in the same language that WordPress is developed in might make my tutorial more useful for the geeky RE.net folks among us. Besides, learning a little PHP never hurt anybody.

In order to use the Trulia API, you first need to get a Trulia user account and then you to register for an account key. After you have your account key, then the fun can begin. The Trulia API is available via a REST Web Service, so it’s pretty familiar if you’ve dealt with XML based web services before. For my tutorial, I decided to create a function that would create a market activity report for a given city. The final result looks something like this…

Market Activity for San Francisco, CA
Week Ending
Date
Number Of
Properties
Median
Listing Price
2007-07-14 1,059 $799,000
2007-07-21 1,068 $801,667
2007-07-28 1,042 $807,667
2007-08-04 902 $801,929
2007-08-11 882 $792,393

Search Real Estate and Homes for Sale

To generate this table I needed to call the TruliaStats.getCityStats web service. The Trulia APIs are different from the Zillow APIs in that they usually return a lot of raw data. The upside of this approach is that the developer has a lot more flexibility on how they want to combine or visualize the results of the web service calls. The downside with this approach is that visualizing the data in cool ways is a fair amount of work. In general, the Zillow API trades off flexibility and power for ease of use (so you can do more interesting things with Trulia API like Truliaholic and other applications, but getting a simple chart with the Zillow API is easier).

Without further ado, here’s the Trulia API / PHP sample code I wrote to create the above table… Just copy and paste it into a PHP page, replace the value of the $apikey variable in the marketwatch function with your API key, and you should be golden.

The code is pretty basic. The first couple lines creates the url used to make the web service call. The next several lines puts the HTTP response from the web service API into an XML DOM. The last several lines traverses the XML DOM, and creates a nice HTML table. If you want a table for a different city or for a different duration, just change the marketwatch function call at the bottom of the page.

Anyway, if any of you are considering using the Trulia API for your web site, I’d recommend you follow their terms of use and post any questions or suggestion you have on their forums. Happy coding!

| More

Enjoy this post? Subscribe to the Geek Estate Blog feed or get updates via e-mail

Delivered by FeedBurner

Comments

View Comments

  1. Robbie Paplin on August 13, 2007 12:09 pm

    I should note that my example code appears to require PHP 5. (Due to my usage of the SimpleXML extension, which apparently doesn’t come with PHP 4).

    I thought I would pass that on in case anybody else tries to run this on PHP 4 and gets a “parse error, unexpected T_OBJECT_OPERATOR” error.

    Sorry about that…

  2. Drew Meyers on August 13, 2007 2:06 pm

    Robbie-
    Now, you’ll just have to write a plug-in using the Zillow API :)

    We have an API addition coming that will give you some more data to work with.

  3. Jay Thompson on August 13, 2007 2:25 pm

    Robbie, I bow to your geekness! I’ll have to give this a whirl, thanks!

  4. Roger from Trulia on August 13, 2007 3:21 pm

    Well done! Now all we need is a Zillow-Trulia mashup that uses both APIs. I built one on my home server but it’s too ugly for public consumption…

  5. ARDELL on August 13, 2007 7:36 pm

    Hi Robbie,

    I got a geeky boy alert and headed over. I don’t see much Seattle Data in Trulia. Is there enough to provide any kind of tables in our area?

  6. Robbie on August 13, 2007 9:14 pm

    Ardell,

    It appears that Trulia has about 17-25% of the inventory that the NWMLS has for the greater Seattle area and the listings that they do have are usually lower in price than the full inventory from the “real thing”. I guess brokers with expensive listings don’t advertise on Trulia much.

    Anyway, I’ve e-mailed you the “Trulia tables” for Seattle, Redmond, Kirkland, and Bellevue, for your reading enjoyment.

  7. Barry J on June 4, 2008 8:18 pm

    Ok … I am so lost with the coding talk. I think I will stick to using widgets that the programmers like you create.

  8. chris on September 30, 2008 1:06 pm

    I get 504 error (timed out) often when using this. Is there away around this? Maybe caching the results or something?

  9. Robbie on October 1, 2008 7:59 am

    I was seeing this last night, but I’m not seeing this today. If the the 504s continue, let me know and I’ll harass my friends at Trulia?

  10. Make your own Zillow Mortgage widget using ASP.net & C# | GeekEstate Blog - Real Estate Technology News and Analysis for Real Estate Professionals on March 7, 2009 10:20 pm

    [...] last time I posted on Geek Estate, I wrote about how to use the Trulia API from a PHP page. Since watching mortgage rates fall is a lot more fun than watching home prices fall, I decided to [...]

Subscribe without commenting

blog comments powered by Disqus

Recent Contributors

Local Market Explorer

Mortgage Center

Recent Comments

  • Eric @ Yorba Linda Homes: Hey Jeff, BofA is getting a LOT better to deal with in terms...
  • TampaAgent: the supra boxes are so OLD technology.. but when you have no...
  • backlink for seo: Do you have any idea to automatic bookmarking to the many bo...
  • Intown Elite: The "branded" Zillow experience may have a small banner with...
  • Annuity Providers In Canada: Major cell phone providers in Canada? I'm moving to Canada n...
  • Intown Elite: I'm in Intown Atlanta. We have lots of 1920s to 1940s homes...
  • : Although a local economist has openly stated that the Maui m...
  • Atlanta Real Estate: This is indeed good news for us local agents that are on bal...
  • BestREMAX: I just called my MLS to get the add-on which is $55 but the...
  • Andrew Mattie: If you really don't like Zillow, you can just completely tur...
  • Andrew Mattie: Yes, Flickr was removed. I had heard quite a few complains a...
  • Andrew Mattie: While the risk of losing visitors is certainly a possibility...

Community

Links

Carnival of Real Estate


Free Subscription: RSS - iTunes

Web Tools

Get Updates via E-mail

Delivered by FeedBurner

RSS

Subscribe via RSS

Categories

Stats

Total Comments: 5979

Admin