Ingesting data from device service with the REST API


This API provides a straightforward method for sending device-related metrics, such as fuel pump data, to your server.

Make sure to provide the required parameters in the request body and set the appropriate headers. The curl example demonstrates a typical API call for sending device metrics. For more information about users, see User access

Before you run an endpoint, you must authenticate yourself. For more information, see Access and authentication for the REST API.

Ingesting data

Use the following API to ingest data from various devices into your system.

POST /metrics
Ingest data from various devices
Request URL
Request URL
http://<localhost>:<Port Number>/api/v2/device/metrics 
Example request URL
bash
curl -X POST http://localhost:54444/api/v2/device/metrics -d '{"key": "value"}' -H 'Content-Type: application/json'

In this example, replace {"key": "value"} it with your JSON payload or data you want to send in the request body. The -H 'Content-Type: application/json header specifies that the content being sent is in the JSON format. You must adjust the payload according to your API requirements. This way, you can make the POST call more generic and adaptable to different scenarios.

Request header
Request header
Content-Type: application/json
 Parameters

Name

Located in

Description

Mandatory

Schema

profileName

query

The profile name is associated with the device.

no

string

deviceId 

query

This parameter is auto-generated and a unique identifier of the device.

no

string

deviceName 

query

The name or identifier of the device. Use this parameter for all APIs.
This parameter is unique across all nodes.  

no

string

isEvent 

query

Indicates whether the data represents an event (true) or not (false).

no

boolean

metrics

query

An array of metric objects, each containing the following fields:

  • name (string): The name of the metric.
  • value (number): The value of the metric.
  • origin (number): The microsecond time stamp when the metric data was recorded.

no

array

Example request body
Example request body
json
{
   "profileName": "FuelPump",
   "deviceId": "2",
   "deviceName": "PStation_1040_FP_2",
   "isEvent": false,
   "metrics": [
       {
           "name": "fp_currentReading_litres",
           "value": 9.878996,
           "origin": 1692599969274000
       },
       {
            "name": "fp_fuelling_rate_liters_per_min",

           "value": 29.878996,
           "origin": 1692599969273000
       }
   ]
}
Example usage with cURL

Here's an example of how you can use the `curl` command to send data to the API:

Example usage with cURL
shell
curl --location 'http://clm-aus-vpn3l3:54444/api/v2/device/metrics' \
--header 'Content-Type: application/json' \
--data '{
   "profileName": "FuelPump",
   "deviceId": "2",
   "deviceName": "PStation_1040_FP_2",
   "isEvent": false,
   "metrics": [
       {
           "name": "fp_currentReading_litres",
           "value": 9.878996,
           "origin": 1692599969274000
       },
       {
           "name": "fp_fuelling_rate_liters_per_min",
           "value": 29.878996,
           "origin": 1692599969273000
       }
   ]
}
Response

The API responds with an appropriate HTTP status code to indicate the success or failure of the request. A successful response has a status code of 200 OK.

Example usage with cURL
200 OK

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*