API recipes

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

Examples

Total the value of homes inside a drawn flood zone

Programming language

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

Total the value of homes inside a drawn flood zone
Draw a shape around a river and total what sits inside it, here the river flats of central Calgary. One request returns the summed estimated sale price and the count of the homes inside the polygon with a flood score of 2 or below, where lower means more exposed. Searching is free, so the request costs two aggregation values whatever the size of the area. A polygon takes at most 100 points.
Request
Shell session
curl -X GET "https://api.houski.ca/aggregate?agg0_aggregation=sum&agg0_field=estimate_sale_price&agg0_score_flood_lte=2&agg1_aggregation=count&agg1_field=estimate_sale_price&agg1_score_flood_lte=2&api_key=YOUR_API_KEY&polygon=51.0560_-114.0950,51.0560_-114.0600,51.0330_-114.0600,51.0330_-114.0950"
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', 'sum');
    url.searchParams.set('agg0_field', 'estimate_sale_price');
    url.searchParams.set('agg0_score_flood_lte', '2');
    url.searchParams.set('agg1_aggregation', 'count');
    url.searchParams.set('agg1_field', 'estimate_sale_price');
    url.searchParams.set('agg1_score_flood_lte', '2');
    url.searchParams.set('api_key', 'YOUR_API_KEY');
    url.searchParams.set('polygon', '51.0560_-114.0950,51.0560_-114.0600,51.0330_-114.0600,51.0330_-114.0950');

    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": true,
  "cost_cents": 2.0,
  "data": [
    {
      "aggregation": "sum",
      "field": "estimate_sale_price",
      "value": "1285652937"
    },
    {
      "aggregation": "count",
      "field": "estimate_sale_price",
      "value": "2185"
    }
  ],
  "error": "",
  "price_quote": false,
  "time_ms": 4334
}