!

API Recipes

Learn how to use the Houski API with practical examples.

Compare median prices across cities

Programming language

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

Compare median prices across cities
Calculate median property prices for multiple cities in a single batch request. This example compares Vancouver and Victoria median listing prices.
Request
Shell session
curl -X GET "https://api.houski.ca/aggregate?agg0_aggregation=median&agg0_city=vancouver&agg0_country_abbreviation=ca&agg0_field=estimate_list_price&agg0_province_abbreviation=bc&agg1_aggregation=median&agg1_city=victoria&agg1_country_abbreviation=ca&agg1_field=estimate_list_price&agg1_province_abbreviation=bc&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', 'vancouver');
    url.searchParams.set('agg0_country_abbreviation', 'ca');
    url.searchParams.set('agg0_field', 'estimate_list_price');
    url.searchParams.set('agg0_province_abbreviation', 'bc');
    url.searchParams.set('agg1_aggregation', 'median');
    url.searchParams.set('agg1_city', 'victoria');
    url.searchParams.set('agg1_country_abbreviation', 'ca');
    url.searchParams.set('agg1_field', 'estimate_list_price');
    url.searchParams.set('agg1_province_abbreviation', 'bc');
    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": "1313213"
    },
    {
      "aggregation": "median",
      "field": "estimate_list_price",
      "value": "796025"
    }
  ],
  "error": "",
  "price_quote": false,
  "time_ms": 31
}