API recipes

Requests you can copy and run. Each one returns live data from the API.

Examples

Calculate median prices by property type

Programming language

Select the programming language you want to display the code examples in.

Median list prices by property type
Median list price of Calgary houses and of Calgary apartments in one batched request. Add more property types as agg2, agg3 and so on.
Request
Shell session
curl -X GET "https://api.houski.ca/aggregate?agg0_aggregation=median&agg0_city=calgary&agg0_country_abbreviation=ca&agg0_field=estimate_list_price&agg0_property_type_eq=House&agg0_province_abbreviation=ab&agg1_aggregation=median&agg1_city=calgary&agg1_country_abbreviation=ca&agg1_field=estimate_list_price&agg1_property_type_eq=Apartment&agg1_province_abbreviation=ab&api_key=YOUR_API_KEY"
TypeScript code
const houski_recipe_data = async (): Promise<AggregateResponse> => {

    // You must copy the AggregateResponse type declarations from the 
    // Houski API documentation to strongly type the response

    const url = new URL('https://api.houski.ca/aggregate');
    url.searchParams.set('agg0_aggregation', 'median');
    url.searchParams.set('agg0_city', 'calgary');
    url.searchParams.set('agg0_country_abbreviation', 'ca');
    url.searchParams.set('agg0_field', 'estimate_list_price');
    url.searchParams.set('agg0_property_type_eq', 'House');
    url.searchParams.set('agg0_province_abbreviation', 'ab');
    url.searchParams.set('agg1_aggregation', 'median');
    url.searchParams.set('agg1_city', 'calgary');
    url.searchParams.set('agg1_country_abbreviation', 'ca');
    url.searchParams.set('agg1_field', 'estimate_list_price');
    url.searchParams.set('agg1_property_type_eq', 'Apartment');
    url.searchParams.set('agg1_province_abbreviation', 'ab');
    url.searchParams.set('api_key', 'YOUR_API_KEY');

    const response = await fetch(url);
    const data = await response.json();

    return data;
}

(async () => {
let data: AggregateResponse = await houski_recipe_data();

// Log the response
console.log(data);
})();
Response
JSON
{
  "cache_hit": false,
  "cost_cents": 2.0,
  "data": [
    {
      "aggregation": "median",
      "field": "estimate_list_price",
      "value": "688903"
    },
    {
      "aggregation": "median",
      "field": "estimate_list_price",
      "value": "429562"
    }
  ],
  "error": "",
  "price_quote": false,
  "time_ms": 41
}