Retrieves list of flow detections. DCM_API_DOMAIN will be provided by DCM.
Request
URL: <DCM_API_DOMAIN>/flows
Method: POST
Format: application/json
Headers: The following headers must be included in the request
|
Parameter |
Type |
Mandatory |
Description |
|---|---|---|---|
|
content-type |
string |
Yes |
Indicates the media type of the resource. Use |
|
authorization Token |
string |
Yes |
Token to be used when accessing the API. Value is Use token from Token. |
Parameters:
|
Parameter |
Type |
Mandatory |
Default Value |
Description |
|---|---|---|---|---|
|
query |
string |
Yes |
|
A structured string that allows calling application to specify the data that it wants to retrieve. |
Query structure:
query {
flows(calibrationId: <calibration_id>, startTime: <start_time>, endTime: <end_time>, timezone: <timezone>) {
<data_fields_to_be_retrieved>
}
}
Query Parameters: The following are parameters to be included in the request.
|
Parameter |
Type |
Mandatory |
Default Value |
Description |
|---|---|---|---|---|
|
calibration_id |
Integer |
Yes |
|
The Id of the calibration (camera view) that data is required for. The list of valid calibrations can be retrieved with the /calibrations endpoint. |
|
start_time |
DateTime |
No |
Now - 1 hour |
The start of the period data is requested for Time periods are in UTC format and can be a maximum of a 24 hour period. |
|
end_time |
DateTime |
No |
Now |
The end of the period data is requested for |
|
timezone |
String |
No |
Etc/UTC |
The timezone name for parameters and data (IANA timezone database specification). See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for the list of timezone names. Eg. “Australia/Sydney”, “Europe/London” |
|
data_fields_to_be_retrieved |
string |
Yes |
|
The fields to be retrieved. Allowed values:
|
Notes:
-
If end_time is more than 1 day after start_time an error will occur and no data will be retrieved.
Response
Format: application/json
Parameters:
|
Name |
Type |
Description |
|---|---|---|
|
errors.message |
String |
Description of the error if one occurred. |
|
data.flows |
List |
List of flow detections. |
Examples
-
Retrieve all flow fields
const getFlows = async function(token, calibrationId, startTime, endTime) {
return new Promise(function(res, rej) {
const url = '<DCM_API_DOMAIN>/flows';
const method = 'POST';
const headers = {
'content-type': 'application/json',
'authorizationToken': `Bearer ${token}`
};
const query = `query {
flows(calibrationId: "${calibrationId}", startTime: ${startTime}, endTime: ${endTime}) {
timestamp
speed
}
}`;
const options = {
url: url,
method: method,
headers: headers,
body: JSON.stringify({ query })
};
const req = request(options, function callback(error, response, body) {
body = JSON.parse(body);
...
...
});
});
}
Response
{
"data": {
"flows": [
{
"timestamp": "2021-12-08T06:02:50.476Z",
"speed": 0.322
}
]
}
}