!

/aggregate

GET
https://api.houski.ca/aggregate

This endpoint returns averages of property data for a given location. You can use this endpoint to get an overview of the property market or property features in a specific area.

This endpoint handles single and batch requests. Batch requests, which enable multiple operations with varying fields, aggregations, and filters in one go, are more efficient than multiple single requests.

Example use cases

  1. Real estate analysts can perform granular market trend analysis by comparing average property prices, square footage, or other characteristics across different neighborhoods or cities.
  2. Provide potential buyers or renters with insights into the average costs of properties (e.g., rent, purchase price) in different areas, enhancing their search experience.
  3. Assist real estate investors in identifying undervalued areas by comparing the average property values against regional income levels.
  4. Portfolio managers can assess the performance of their real estate investments by tracking changes in the average value of properties within their portfolio over time.
  5. Support government housing authorities in monitoring and developing policies related to affordable housing by analyzing the average prices of properties across different zones.

Request parameters

NameRequiredTypeDescription
api_keyYesUUID v4Your API key for authorization
fieldYesStringThe field to be aggregated - see fields for all available fields
aggregationYesStringThe aggregation type (e.g., sum, mean, median, mode, quantile-10, quantile-25, etc.)
country_abbreviationNoStringA country abbreviation
province_abbreviationNoStringA province abbreviation within the country
cityNoStringA city within the province
communityNoStringA community within the city

Response object

Type declarations are available at the bottom of this page.

NameTypeDescription
cache_hitBooleanIndicates if the response was a cache hit
cost_centsNumberCost of the request in cents
dataObjectContains the data for the aggregation
errorStringDetails about the error. Empty if no error
price_quoteBooleanIndicates whether the response is a price quote
time_msNumberTime taken for the request to complete in milliseconds

Example requests and responses

Programming language

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

Get the average list price in a community
This request returns the median list price of properties in the Riverbend community in Calgary, Alberta, Canada.
Request
Shell session
curl -X GET "https://api.houski.ca/aggregate?aggregation=median&api_key=YOUR_API_KEY&city=calgary&community=riverbend&country_abbreviation=ca&field=estimate_list_price&province_abbreviation=ab"
TypeScript code
const houski_get_aggregate = 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('community', 'riverbend');
    url.searchParams.set('country_abbreviation', 'ca');
    url.searchParams.set('field', 'estimate_list_price');
    url.searchParams.set('province_abbreviation', 'ab');

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

    return data;
}

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

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

Batch request example

Multiple batched aggregate query
This request performs multiple aggregate operations batched together.
Request
Shell session
curl -X GET "https://api.houski.ca/aggregate?agg0_aggregation=sum&agg0_city=edmonton&agg0_country_abbreviation=ca&agg0_field=bedroom&agg0_property_type_eq=Apartment&agg0_province_abbreviation=ab&agg1_aggregation=median&agg1_city=calgary&agg1_country_abbreviation=ca&agg1_field=estimate_list_price&agg1_property_type_eq=House&agg1_province_abbreviation=ab&api_key=YOUR_API_KEY"
TypeScript code
const houski_get_aggregate_batch = 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_city', 'edmonton');
    url.searchParams.set('agg0_country_abbreviation', 'ca');
    url.searchParams.set('agg0_field', 'bedroom');
    url.searchParams.set('agg0_property_type_eq', 'Apartment');
    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', 'House');
    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_get_aggregate_batch();

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

Response type declarations

TypeScript code
interface AggregateResponse {
    cache_hit: boolean;
    cost_cents: number;
    data: AggregateData[];
    error: string;
    price_quote: boolean;
    time_ms: number;
}

interface AggregateData {
    field: string;
    aggregation: string;
    value: string;
}