!

API Recipes

Learn how to use the Houski API with practical examples.

Calculate median prices by property type

Programming language

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

Median house prices by property type
Calculate the median listing price for houses in Calgary. You can filter by property type to analyze specific segments of the market.
Request
Shell session
curl -X GET "https://api.houski.ca/aggregate?aggregation=median&api_key=YOUR_API_KEY&city=calgary&country_abbreviation=ca&field=estimate_list_price&property_type_eq=House&province_abbreviation=ab"
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('aggregation', 'median');
    url.searchParams.set('api_key', 'YOUR_API_KEY');
    url.searchParams.set('city', 'calgary');
    url.searchParams.set('country_abbreviation', 'ca');
    url.searchParams.set('field', 'estimate_list_price');
    url.searchParams.set('property_type_eq', 'House');
    url.searchParams.set('province_abbreviation', 'ab');

    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": 1.0,
  "data": [
    {
      "aggregation": "median",
      "field": "estimate_list_price",
      "value": "753406"
    }
  ],
  "error": "",
  "price_quote": false,
  "time_ms": 84
}