Read Metrics
To read existing metrics, you will need to make a TLS request to the OpenHIM API for the below method and endpoint. The two query parameters startDate
and endDate
have to be supplied (datetime format).
#
Read all metrics#
Read metrics broken down by channel#
Read metrics for a specific channel#
Read metrics in a specified timeSeriesTime series values are one of 'minute', 'hour', 'day', 'month', 'year'.
#
Read metrics broken down by channel in a specified timeSeries#
Read metrics for a specific channel in a specified timeSeriesThe metrics API always returns a JSON array with the metrics. If the channel does not exist the api responds with a status of 401
, and 200
on success.
#
ExampleNote: In the examples below, we are using the token authentication type to authenticate requests
Before we can send our request to the OpenHIM API we need to ensure that we construct our valid HTTP headers to successfully authenticate with the OpenHIM API.
- NodeJS
- Bash
Copy the below code at the bottom of your nodejs script that handles the authentication of the OpenHIM headers as described in the authentication section.
Replace the openhimOptions
values with the correct implementation details
Ensure that you have created your bash script to construct the HTTP authentication headers and send the request to the OpenHIM API as described in the authentication section.
Execute the below command in your terminal where the file is located with the required arguments. Replace the placeholder arguments with the correct implementation details. Make sure to pass valid dates for the startDate
and endDate
.
The response status code will be 200
if successful.