We use the myAirCoach Asthma inhaler device as an example to describe to you how you can connect your sensor or wearable device to our Sensor data API.

Authentication

IMPORTANT

This example uses the public endpoint, do not store sensitive information using this endpoint!

Before measurements can be stored, the user needs to login to obtain a valid JWT. The user can login using one of the authentication APIs.

For example using curl:

$ curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{
  \"password\": \"demo\",
  \"email\": \"demo@medsafe\"
}" "https://dev.medrecord.nl/auth/login/password"

This will return some information about the user and a token. Pass this token on every request and remember the mvUid. Please note this token expires and need to be refreshed periodically.

Sending events and data

To send an event, the event API can be used.

This API accepts a document with measured data, locations and device type:

{
  "data": [
    {
      "type": "environment.ambient_temperature",
      "value": [
        {
          "value": 19.6,
          "timestamp": "2017-02-13T12:00Z"
        }
      ]
    },
    {
      "type": "environment.ambient_humidity",
      "value": [
        {
          "value": 100,
          "timestamp": "2017-02-13T12:00Z"
        }
      ]
    }    
  ],
  "location": {
    "latitude": 52.2393325,
    "longitude": 4.7243179
  },
  "device": {
    "id": "123456789",
    "type": "medical.inhaler.mac"
  },
  "timestamp": "2017-02-13T12:00Z"
}

For example using curl:

Save the document to a file called body.json and use the following replacing mvUid and token with the correct values:

$ curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" \
-d @body.json \
"https://dev.medrecord.nl/dgs/mvUid/event/device.inhaler.shaking?authToken=token"

You will not see any output if the request was successful.

Available types

  • device type:
    • medical.inhaler.mac
  • event type:
    • device.inhaler.shaking
    • device.inhaler.activation
  • data type:
    • environment.ambient_temperature in degrees Celcius
    • environment.ambient_humidity in percentages
    • environment.atmospheric_pressure in millibar
    • device.inhaler.position

Further information

  • Java client library
pluslistarrow-leftglobe