The HouseMath API.
Here is the first pass at the long-awaited HouseMath API. The API allows any web developer to use the HouseMath calculation engine on their site. The first version provides three basic functions:
- describe_scenarios
- This is a function you call to get a list of all the scenarios currently available in HouseMath (as XML). The list is growing all the time, so it's a useful call for discovering new ways to do new analytics. This is the source of the important scenarioid variable used to identify which scenario you plan to work on.
- describe_analysis
- Gives you a complete description of all the parameters HouseMath uses to perform an analysis (as XML). This can be a quick call to just get a list of variables (FYI, if you know them you do not need a description), or a call that returns result of various degrees of complexity including parameter names, default values, units, unit labels, parameters validators, sample calculations, and even LaTex equations for each calculation used. Basically it is everything one might need to build another HouseMath app in the language of their choice, including the fancy math in the HouseMath Wiki.
- calculate
- Accepts parameters for various variables that are needed to calculate a scenario. If any parameters are not passed, the defaults are used. The function returns a complete set of reports with variables, intermediate calculations, etc. All in XML.
Sample Code
As some of you know, HouseMath is written in Ruby + Ruby/Rails and is relying on YUI and YUI-EXT for its user interface. However, there are other ways to skin a cat. I provide sample code in Ruby/Rails (obviously) and PHP 5.0. Any web development language that can make an HTTP GET request, parse the result as XML, and then work with it will do. I have a secret dream of putting up a version of HouseMath in Adobe Flex... "had we but world enough and time" as Andrew Marvel put it.
XML Schemas
I want to be a good citizen, so there are XSD schemas provided for all XML results. I would not necessarily use the schema locations for validation because those locations might change, but schemas are there for anyone to download and use.
Enjoy
Loading...