API recipes

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

Examples

Compare median price per square metre across cities and countries

Programming language

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

Compare median price per square metre across cities and countries
Median estimated sale price per square metre in Toronto, Manchester, Paris and Madrid in one batched request. Every country carries the same fields, so one request compares them all. Money is in each country's own currency (Canadian dollars, pounds sterling and euros here) with no exchange rate applied.
Request
Shell session
curl -X GET "https://api.houski.ca/aggregate?agg0_aggregation=median&agg0_city=toronto&agg0_country_abbreviation=ca&agg0_field=estimate_sale_price_per_sq_m&agg0_province_abbreviation=on&agg1_aggregation=median&agg1_city=manchester&agg1_country_abbreviation=gb&agg1_field=estimate_sale_price_per_sq_m&agg1_province_abbreviation=eng&agg2_aggregation=median&agg2_city=paris&agg2_country_abbreviation=fr&agg2_field=estimate_sale_price_per_sq_m&agg2_province_abbreviation=idf&agg3_aggregation=median&agg3_city=madrid&agg3_country_abbreviation=es&agg3_field=estimate_sale_price_per_sq_m&agg3_province_abbreviation=mad&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', 'toronto');
    url.searchParams.set('agg0_country_abbreviation', 'ca');
    url.searchParams.set('agg0_field', 'estimate_sale_price_per_sq_m');
    url.searchParams.set('agg0_province_abbreviation', 'on');
    url.searchParams.set('agg1_aggregation', 'median');
    url.searchParams.set('agg1_city', 'manchester');
    url.searchParams.set('agg1_country_abbreviation', 'gb');
    url.searchParams.set('agg1_field', 'estimate_sale_price_per_sq_m');
    url.searchParams.set('agg1_province_abbreviation', 'eng');
    url.searchParams.set('agg2_aggregation', 'median');
    url.searchParams.set('agg2_city', 'paris');
    url.searchParams.set('agg2_country_abbreviation', 'fr');
    url.searchParams.set('agg2_field', 'estimate_sale_price_per_sq_m');
    url.searchParams.set('agg2_province_abbreviation', 'idf');
    url.searchParams.set('agg3_aggregation', 'median');
    url.searchParams.set('agg3_city', 'madrid');
    url.searchParams.set('agg3_country_abbreviation', 'es');
    url.searchParams.set('agg3_field', 'estimate_sale_price_per_sq_m');
    url.searchParams.set('agg3_province_abbreviation', 'mad');
    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": 4.0,
  "data": [
    {
      "aggregation": "median",
      "field": "estimate_sale_price_per_sq_m",
      "value": "7867.718"
    },
    {
      "aggregation": "median",
      "field": "estimate_sale_price_per_sq_m",
      "value": "2944.968"
    },
    {
      "aggregation": "median",
      "field": "estimate_sale_price_per_sq_m",
      "value": "10676.676"
    },
    {
      "aggregation": "median",
      "field": "estimate_sale_price_per_sq_m",
      "value": "6301.288"
    }
  ],
  "error": "",
  "price_quote": false,
  "time_ms": 31
}