Official Plugins (Kuzzle v2.x)
Device Manager v2.x
2

exportMeasures #

This action allow to export the measures history of an device.

The measures are exported as a CSV stream.

The export process have two steps:

  1. execute the exportMeasures action with WebSocket or HTTP POST to prepare an export and retrieve an export link
  2. GET request to the generated export link through a tag <a href="{export-link}">Download</a>

Those two steps are necessary to avoid the browser to crash when exporting a lot of data.

Export link are valid for 2 minutes.

The generated export link does not have protocol, host and port. They should be added to the url.

For example:

// Query to `device-manager/devices:exportMeasures`
const { result } = await sdk.query({ ... });

const fullLink = `http${sdk.protocol.ssl ? 's' : ''}://${sdk.protocol.host}:${sdk.protocol.port}${result.link}`;

Query Syntax #

HTTP #

POST: http://kuzzle:7512/_/device-manager/:engineId/devices/:_id/measures/_export
GET: device-manager/:engineId/devices/:_id/measures/_export/:exportId

Other protocols #

{
  "controller": "device-manager/devices",
  "action": "exportMeasures",
  "engineId": "<engineId>",
  "_id": "<deviceId>",
  "body": {
    "query": {
      // ...
    },
    "sort": [
      // ...
    ]
  },

  // optional:
  "startAt": "<beginning of time range>",
  "endAt": "<end of time range>",
  "type": "<measure type>"
}

Arguments #

  • engineId: engine id
  • _id: device id ISO_8601
  • startAt: beginning of time range (ISO 8601)
  • endAt: end of time range (ISO 8601)
  • type: measure type

Body properties #


Response #

{
  "status": 200,
  "error": null,
  "controller": "device-manager/devices",
  "action": "search",
  "requestId": "<unique request identifier>",
  "result": {
    "link": " /_/device-manager/<engine id>/devices/<device id>/measures/_export/<export id>?jwt=<token>"
  }
}