Social Distances

Retrieves list of social distance measurements. DCM_API_DOMAIN will be provided by DCM.

Request

URL: <DCM_API_DOMAIN>/socialdistances

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 application/json.

authorization Token

string

Yes

Token to be used when accessing the API. Value is Bearer <token>.

Use token from Token. audience is ext-api-socialdistance.

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 {
    socialdistances(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:

  • timestamp

  • distance

  • compliance

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.socialdistances

List

List of Social Distance and compliance.

Examples

  1. Retrieve all flow fields

const getSocialDistances = async function(token, calibrationId, startTime, endTime) {
    return new Promise(function(res, rej) {
        const url =  '<DCM_API_DOMAIN>/socialdistances';
        const method = 'POST';
        const headers = { 
            'content-type': 'application/json',
            'authorizationToken': `Bearer ${token}`
        };
        const query = `query {
            socialdistances(calibrationId: "${calibrationId}", startTime: ${startTime}, endTime: ${endTime}) {
                timestamp
                distance
                compliance
            }
        }`;
        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": {
    "socialdistances": [
      {
        "timestamp": "2021-12-08T06:02:50.476Z",
        "distance": 1.2,
        "compliance": 0.68
      }
    ]
  }
}