Skip to main content

get JWT for CSV Auth

GET 

/user-token

With the JWT you receive in this response, you can authenticate requests to download various CSV reports.

To do so, first hit any of the above report endpoints with csv: true in the request body. The response will have a property csv: { url: exampleUrl, expires: date }.

To download the CSV report, simply append the JWT to the exampleUrl like so:

https://exampleUrl?token={{JWT}}

Endpoint Example Usage

First, hit the endpoint for the report that supports CSV format.

CSV Report Request Body
{
"start":"2019-05-01T00:00:00Z",
"end":"2019-05-05T00:00:00Z",
"data": [
{"metric":"timeInCycle"}
],
"groupBy":[
{"group":"day"},
{"group":"machine"}
],
"filter": {
"machine": ["6fe43f3a-5415-49bf-8830-549ca55b78ea", "e823053c-05b7-4a39-9e1a-0858e44c4284", "f076a4cf-f308-443a-9df7-2b4d68dd7c58"]
},
"csv": true
}
CSV Report Response Body
{
"range": {
"start": "2019-05-01T00:00:00.000Z",
"end": "2019-05-05T00:00:00.000Z"
},
"csv": {
"url": "https://api.machinemetrics.com/csv/production/{{resourceId}}",
"expires": "2019-09-18T00:00:00.000Z"
},
"aggregate": {
"timeInCycle": 1060874083
},
"entities": {...},
"items": [{...},{...}]
}

This will generate a CSV report that you will be able to request using a JWT for added security. Now send a GET request to /user-token to receive a user-token JWT response. To download the CSV report, simple append the {{JWT}} to the CSV url like so:

https://api.machinemetrics.com/csv/production/{{resourceId}}?token={{JWT}}

Note that some of the CSV endpoints allow for additional configuration options via query parameters, such as localize for the production report CSV request.

Responses

JWT that can be used to authenticate CSV download links.