# Aggregates

Aggregates refer to historical, pre-computed statistics and counts of events that occur at specific curbside locations, summarized on an hourly basis. These aggregates provide a consolidated view of event activity over time, helping to identify trends and patterns in curb usage. The data used to generate these aggregates is derived from sessions recorded in the system, which captures detailed information about individual events. By analyzing these hourly aggregates, cities and organizations can gain insights into curbside activities, such as peak usage times, frequency of events, and overall trends, which can inform planning and operational strategies.

## Query Aggregates

> Access metrics data in the Curb Data Specification format. Requires the \`start\_time\` and \`end\_time\` parameters. The \`curb\_place\_type\` and \`curb\_place\_id\` parameters are optional.<br>

```json
{"openapi":"3.1.0","info":{"title":"CurbIQ API","version":"1.0.0"},"servers":[{"url":"https://v2.curbiq-curb-api.io","description":"CurbIQ's Curb API (v1)"}],"paths":{"/metrics/aggregates":{"get":{"operationId":"getAggregates","summary":"Query Aggregates","description":"Access metrics data in the Curb Data Specification format. Requires the `start_time` and `end_time` parameters. The `curb_place_type` and `curb_place_id` parameters are optional.\n","parameters":[{"name":"curbiq_token","in":"query","required":true,"schema":{"type":"string"},"description":"Required for client authentication to query the database."},{"name":"curb_place_type","in":"query","schema":{"type":"string"},"description":"CDS  \nThe type of curb place this aggregate applies to from the Curbs API: area, zone, space.\n"},{"name":"curb_place_id","in":"query","schema":{"type":"string","format":"uuid"},"description":"CDS  \nThe ID of this curb place.\n"},{"name":"metric_type","in":"query","schema":{"type":"string"},"description":"CDS  \nThe metric this aggregate applies to: total_sessions, average_dwell_time, occupancy_percent\n"},{"name":"lat","in":"query","schema":{"type":"number","format":"float"},"required":false,"description":"CDS  \nLatitude at the center of the search circle.  \nThis parameter is conditionally required if either 'lng' or 'radius' is specified.\n"},{"name":"lng","in":"query","schema":{"type":"number","format":"float"},"required":false,"description":"CDS  \nLongitude at the center of the search circle.  \nThis parameter is conditionally required if either 'lat' or 'radius' is specified.\n"},{"name":"radius","in":"query","schema":{"type":"number","format":"float"},"required":false,"description":"CDS  \nRadius of the search circle (in centimeters).  \nThis parameter is conditionally required if either 'lat' or 'lng' is specified.\n"},{"name":"min_lat","in":"query","schema":{"type":"number","format":"float"},"required":false,"description":"CDS  \nFor querying policies associated with all zones within a bounding box.  \nIf any of 'min_lat', 'min_lng', 'max_lat', or 'max_lng' are specified, all must be.  \nIf specified only return Curb Zones that intersect the supplied bounding box.\n"},{"name":"min_lng","in":"query","schema":{"type":"number","format":"float"},"required":false,"description":"CDS  \nFor querying policies associated with all zones within a bounding box.  \nIf any of 'min_lat', 'min_lng', 'max_lat', or 'max_lng' are specified, all must be.  \nIf specified only return Curb Zones that intersect the supplied bounding box.\n"},{"name":"max_lat","in":"query","schema":{"type":"number","format":"float"},"required":false,"description":"CDS  \nFor querying policies associated with all zones within a bounding box.  \nIf any of 'min_lat', 'min_lng', 'max_lat', or 'max_lng' are specified, all must be.  \nIf specified only return Curb Zones that intersect the supplied bounding box.\n"},{"name":"max_lng","in":"query","schema":{"type":"number","format":"float"},"required":false,"description":"CDS  \nFor querying policies associated with all zones within a bounding box.  \nIf any of 'min_lat', 'min_lng', 'max_lat', or 'max_lng' are specified, all must be.  \nIf specified only return Curb Zones that intersect the supplied bounding box.\n"},{"name":"start_time","in":"query","schema":{"type":"integer","format":"int64"},"required":false,"description":"CDS  \nThe Aggregates object will return all aggregates after this start_time.  \nThis parameter takes a time in the [Timestamp](https://github.com/openmobilityfoundation/curb-data-specification/blob/main/general-information.md#timestamp) format in milliseconds.\nOtherwise, the server should reply with 404 Not Found. Availability data (if supplied) will be returned as of this time.\n"},{"name":"end_time","in":"query","schema":{"type":"integer","format":"int64"},"required":false,"description":"CDS  \nThe Aggregates object will return all aggregates before this end_time.  \nThis parameter takes a time in the [Timestamp](https://github.com/openmobilityfoundation/curb-data-specification/blob/main/general-information.md#timestamp) format in milliseconds.\nOtherwise, the server should reply with 404 Not Found. Availability data (if supplied) will be returned as of this time.\n"},{"name":"response_size","in":"query","schema":{"type":"integer"},"description":"CCDS  \nDefault is 100. The maximum response size is 250.\n"},{"name":"page_num","in":"query","schema":{"type":"integer"},"description":"CCDS  \nPage number for paginated responses, default is 1.\n"}],"responses":{"200":{"description":"Successful response. Aggregates as comma-separated values."},"400":{"description":"Bad request. Error in the query parameters such as an invalid token."}},"tags":["metrics"]}}}}
```

**Note:**\
Custom response limits have been placed to manage query operations/system loads and response time.

* If a `curb_place_id` is not specified: `end_time - start_time` should not exceed two weeks
* If a `curb_place_id` is specified: `end_time - start_time` should not exceed three months
