REST Documentation (1.0.0)
The MachineMetrics REST APIs are a set of endpoints that can be used for generating historical reports, downloading CSVs of those results, and pushing data into MachineMetrics from other systems like ERPs.
Production queries are the highly powerful mechanism that is used to drive much of the reporting in the MachineMetrics application including the Report Builder.
With the ability to query for various KPIs such as OEE, Downtime, and Quality including their subcomponents across large spans of time, you can use this API to integrate with various Business Intelligence tools. Use this endpoint to watch for historical trends, address high impact reasons for downtime, and make sure you're meeting your production standards.
Get Production Query Results
Retrieve selected data metrics rollups for a given time frame.
Authorizations:
Request Body schema: application/jsonrequired
Production Query Object
startDay required | string <date> Must be a valid ISO 8601 date format (e.g., "2017-07-19"); startDay must be before or equal to endDay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
endDay required | string <date> Must be a valid ISO 8601 date format (e.g., "2017-07-19"); endDay must be after or equal to startDay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
required | Array of objects The Example usage:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Array
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Array of objects Groups and aggregates the Example usage:
This will group and aggregate your selected | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Array
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
object Filters your query to include results for the items whose id is supplied in each respective array only. If the array is not supplied, or is empty, no filtering will be done on that item. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
csv | boolean When See operations for JWT generation and jwtAuth securities definition for more information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
flatten | boolean When |
Responses
Request samples
- Payload
{- "start": "2017-07-19T10:00:00Z",
- "end": "2017-07-21T10:00:00Z",
- "data": [
- {
- "metric": "totalParts"
}, - {
- "metric": "timeInCycle"
}
], - "groupBy": [
- {
- "group": "day"
}, - {
- "group": "machine"
}
], - "filter": {
- "machine": [
- "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c",
- "5faa6680-fa0f-4e37-ba0b-09a46a945cef",
- "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013"
]
}
}
Response samples
- 200
- 401
- 403
- 404
{- "range": {
- "start": "2017-07-19T10:00:00.000Z",
- "end": "2017-07-21T10:00:00.000Z"
}, - "aggregate": {
- "totalParts": 8824,
- "timeInCycle": 291068400
}, - "entities": {
- "day": {
- "0": {
- "start": "2017-07-19T10:00:00.000Z",
- "end": "2017-07-20T10:00:00.000Z",
- "shopDate": "2017-07-19T04:00:00.000Z"
}, - "1": {
- "start": "2017-07-20T10:00:00.000Z",
- "end": "2017-07-21T10:00:00.000Z",
- "shopDate": "2017-07-20T04:00:00.000Z"
}
}, - "machine": {
- "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c": {
- "id": "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c",
- "name": "MACHINE 1"
}, - "5faa6680-fa0f-4e37-ba0b-09a46a945cef": {
- "id": "5faa6680-fa0f-4e37-ba0b-09a46a945cef",
- "name": "MACHINE 2"
}, - "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013": {
- "id": "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013",
- "name": "MACHINE 3"
}
}
}, - "items": [
- {
- "entity": {
- "type": "day",
- "id": "0"
}, - "aggregate": {
- "totalParts": 4295,
- "timeInCycle": 146361236
}, - "items": [
- {
- "entity": {
- "type": "machine",
- "id": "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013"
}, - "aggregate": {
- "totalParts": 0,
- "timeInCycle": 9971
}
}, - {
- "entity": {
- "type": "machine",
- "id": "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c"
}, - "aggregate": {
- "totalParts": 3425,
- "timeInCycle": 80549950
}
}, - {
- "entity": {
- "type": "machine",
- "id": "5faa6680-fa0f-4e37-ba0b-09a46a945cef"
}, - "aggregate": {
- "totalParts": 870,
- "timeInCycle": 65801315
}
}
]
}, - {
- "entity": {
- "type": "day",
- "id": "1"
}, - "aggregate": {
- "totalParts": 4529,
- "timeInCycle": 144707164
}, - "items": [
- {
- "entity": {
- "type": "machine",
- "id": "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013"
}, - "aggregate": {
- "totalParts": 978,
- "timeInCycle": 19536320
}
}, - {
- "entity": {
- "type": "machine",
- "id": "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c"
}, - "aggregate": {
- "totalParts": 2741,
- "timeInCycle": 64656182
}
}, - {
- "entity": {
- "type": "machine",
- "id": "5faa6680-fa0f-4e37-ba0b-09a46a945cef"
}, - "aggregate": {
- "totalParts": 810,
- "timeInCycle": 60514662
}
}
]
}
]
}
Get Production Results CSV
Retrieve the results of a production metrics rollup request in CSV format.
Authorizations:
path Parameters
resourceId required | integer Dynamic resource ID for CSV download path - resource expiry date is specified alongside resource ID in response body. |
query Parameters
token required | string <password> See operations for JWT generation and jwtAuth securities definition for more information. |
localize | boolean Default: false Option that enables the following CSV formatting options:
|
Responses
Response samples
- 401
- 404
{- "error": "invalid_token",
- "error_description": "Invalid token: access token is invalid"
}
Downtime queries are great for building downtime paretos, but can also be leveraged to watch for trends in your downtime reasons over time. Grouping your data by shift and other details like the operation running on the machine can provide deeper insight into where your bottlenecks are.
Get Downtime Query Results
Retrieve downtime (ms) rollups for a given time frame.
Authorizations:
Request Body schema: application/jsonrequired
Downtime Query Object
start required | string <date-time> Must be a valid ISO 8601 date-time format (e.g., "2017-07-19T10:00:00Z"); start must be before end | ||||||||||||||||||||
end required | string <date-time> Must be a valid ISO 8601 date-time format (e.g., "2017-07-19T10:00:00Z"); end must be after start | ||||||||||||||||||||
Array of objects Groups and aggregates the Example usage:
This will group and aggregate | |||||||||||||||||||||
Array
| |||||||||||||||||||||
object Filters your query to include results for the items whose id is supplied in each respective array only. If the array is not supplied, or is empty, no filtering will be done on that item. | |||||||||||||||||||||
| |||||||||||||||||||||
csv | boolean When See operations for JWT generation and jwtAuth securities definition for more information. | ||||||||||||||||||||
flatten | boolean When |
Responses
Request samples
- Payload
{- "start": "2017-07-19T10:00:00Z",
- "end": "2017-08-19T10:00:00Z",
- "groupBy": [
- {
- "group": "reason"
}, - {
- "group": "machine"
}
], - "filter": {
- "machine": [
- "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c",
- "5faa6680-fa0f-4e37-ba0b-09a46a945cef",
- "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013"
]
}
}
Response samples
- 200
- 401
- 403
- 404
{- "range": {
- "start": "2017-07-19T10:00:00.000Z",
- "end": "2017-08-19T10:00:00.000Z"
}, - "aggregate": {
- "downtimeMs": 7644699,
- "recordCount": 8
}, - "entities": {
- "reason": {
- "33": {
- "id": 33,
- "name": "Chipping Out",
- "color": "#dea638"
}, - "95": {
- "id": 95,
- "name": "Part Changeover",
- "color": "#de7020"
}, - "uncategorized": {
- "id": "uncategorized",
- "name": "Uncategorized",
- "color": "#444444",
- "virtual": true
}, - "setup": {
- "id": "setup",
- "name": "Setup",
- "color": "#edde00",
- "virtual": true
}
}, - "machine": {
- "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c": {
- "id": "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c",
- "name": "MACHINE 1"
}, - "5faa6680-fa0f-4e37-ba0b-09a46a945cef": {
- "id": "5faa6680-fa0f-4e37-ba0b-09a46a945cef",
- "name": "MACHINE 2"
}, - "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013": {
- "id": "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013",
- "name": "MACHINE 3"
}
}
}, - "items": [
- {
- "entity": {
- "type": "reason",
- "id": "33"
}, - "aggregate": {
- "downtimeMs": 1731898,
- "recordCount": 4
}, - "items": [
- {
- "entity": {
- "type": "machine",
- "id": "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c"
}, - "aggregate": {
- "downtimeMs": 544259,
- "recordCount": 2
}
}, - {
- "entity": {
- "type": "machine",
- "id": "5faa6680-fa0f-4e37-ba0b-09a46a945cef"
}, - "aggregate": {
- "downtimeMs": 837607,
- "recordCount": 1
}
}, - {
- "entity": {
- "type": "machine",
- "id": "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013"
}, - "aggregate": {
- "downtimeMs": 350032,
- "recordCount": 1
}
}
]
}, - {
- "entity": {
- "type": "reason",
- "id": "95"
}, - "aggregate": {
- "downtimeMs": 5912801,
- "recordCount": 4
}, - "items": [
- {
- "entity": {
- "type": "machine",
- "id": "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013"
}, - "aggregate": {
- "downtimeMs": 5912801,
- "recordCount": 4
}
}
]
}
]
}
Get Downtime Results CSV
Retrieve the results of a downtime metrics rollup request in CSV format.
Authorizations:
path Parameters
resourceId required | integer Dynamic resource ID for CSV download path - resource expiry date is specified alongside resource ID in response body. |
query Parameters
token required | string <password> See operations for JWT generation and jwtAuth securities definition for more information. |
Responses
Response samples
- 401
- 404
{- "error": "invalid_token",
- "error_description": "Invalid token: access token is invalid"
}
Quality queries give you the power to generate paretos that help you see where your biggest wastes are when it comes to scrap and non-conform pieces. Rejects can be grouped by reason, machine, shift, and even the operation the rejected part was for. Query for totals to build a downtime pareto, or look for trends by requesting by-day or by-week rollups.
Get Quality Query Results
Retrieve rejectCount rollups for a given time frame.
Authorizations:
Request Body schema: application/jsonrequired
Quality Query Object
start required | string <date-time> Must be a valid ISO 8601 date-time format (e.g., "2017-07-19T10:00:00Z"); start must be before end | ||||||||||||||||||
end required | string <date-time> Must be a valid ISO 8601 date-time format (e.g., "2017-07-19T10:00:00Z"); end must be after start | ||||||||||||||||||
Array of objects Groups and aggregates the Example usage:
This will group and aggregate | |||||||||||||||||||
Array
| |||||||||||||||||||
object Filters your query to include results for the items whose id is supplied in each respective array only. If the array is not supplied, or is empty, no filtering will be done on that item. | |||||||||||||||||||
| |||||||||||||||||||
csv | boolean When See operations for JWT generation and jwtAuth securities definition for more information. | ||||||||||||||||||
flatten | boolean When |
Responses
Request samples
- Payload
{- "start": "2017-07-19T10:00:00Z",
- "end": "2017-08-19T10:00:00Z",
- "groupBy": [
- {
- "group": "reason"
}, - {
- "group": "machine"
}
], - "filter": {
- "machine": [
- "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c",
- "5faa6680-fa0f-4e37-ba0b-09a46a945cef",
- "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013"
]
}
}
Response samples
- 200
- 401
- 403
- 404
{- "range": {
- "start": "2017-07-19T10:00:00.000Z",
- "end": "2017-08-19T10:00:00.000Z"
}, - "aggregate": {
- "rejectCount": 150,
- "recordCount": 75
}, - "entities": {
- "reason": {
- "24": {
- "id": 24,
- "name": "Chip Impressions",
- "color": "#5f5da8"
}, - "37": {
- "id": 37,
- "name": "Burrs",
- "color": "#14f2e5"
}
}, - "machine": {
- "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c": {
- "id": "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c",
- "name": "MACHINE 1"
}, - "5faa6680-fa0f-4e37-ba0b-09a46a945cef": {
- "id": "5faa6680-fa0f-4e37-ba0b-09a46a945cef",
- "name": "MACHINE 2"
}, - "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013": {
- "id": "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013",
- "name": "MACHINE 3"
}
}
}, - "items": [
- {
- "entity": {
- "type": "reason",
- "id": "24"
}, - "aggregate": {
- "rejectCount": 25,
- "recordCount": 10
}, - "items": [
- {
- "entity": {
- "type": "machine",
- "id": "0e871f8e-a48a-4a7b-ba33-a02cba7d4f2c"
}, - "aggregate": {
- "rejectCount": 15,
- "recordCount": 5
}
}, - {
- "entity": {
- "type": "machine",
- "id": "5faa6680-fa0f-4e37-ba0b-09a46a945cef"
}, - "aggregate": {
- "rejectCount": 10,
- "recordCount": 5
}
}
]
}, - {
- "entity": {
- "type": "reason",
- "id": "37"
}, - "aggregate": {
- "rejectCount": 125,
- "recordCount": 65
}, - "items": [
- {
- "entity": {
- "type": "machine",
- "id": "5faa6680-fa0f-4e37-ba0b-09a46a945cef"
}, - "aggregate": {
- "rejectCount": 79,
- "recordCount": 53
}
}, - {
- "entity": {
- "type": "machine",
- "id": "f1e76e5f-a9cd-4ae0-9c63-48b78e3cf013"
}, - "aggregate": {
- "rejectCount": 46,
- "recordCount": 12
}
}
]
}
]
}
Get Quality Results CSV
Retrieve the results of a quality metrics rollup request in CSV format.
Authorizations:
path Parameters
resourceId required | integer Dynamic resource ID for CSV download path - resource expiry date is specified alongside resource ID in response body. |
query Parameters
token required | string <password> See operations for JWT generation and jwtAuth securities definition for more information. |
Responses
Response samples
- 401
- 404
{- "error": "invalid_token",
- "error_description": "Invalid token: access token is invalid"
}
get JWT for CSV Auth
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.
Authorizations:
Responses
Response samples
- 200
- 401
- 403
- 404
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
Operations for ERP system integration.
See our simple-erp-integration GitHub repo for a full example.
Start job run
Starts a new job run on a machine.
Authorizations:
Request Body schema: application/jsonrequired
erpJobOperationRunId required | string Unique ID used by the ERP to identify this job run. |
erpMachineId required | string Unique ID used by the ERP to represent the machine for this job run. |
jobName required | string The name of the associated job in MachineMetrics. |
operationName | string or null Default: "" The name of the associated operation in MachineMetrics. Default value is an empty string. |
lotName | string or null Default: "" The name of the associated lot in MachineMetrics. Default value is an empty string. |
partName | string or null Default: "" The name of the associated part in MachineMetrics. Default value is an empty string. |
startInSetup | boolean Default: false If true, the job run will be started in setup; otherwise it will be started in production. |
startAt | string or null <date-time> Default: null The start date and time of the job run in UTC. If not provided, the job run will start at the time of the request. Must be a valid ISO 8601 date-time format (e.g., "2017-07-19T10:00:00Z"). |
jobOperationDescription | string or null Default: null A description of the job. Only used when creating a new job. |
quantityRequired | integer or null Default: null The quantity of parts required for the job. Only used when creating a new job. |
expectedSetupTime | integer or null (seconds) Default: null The amount of time this job run should be expected to be in setup in seconds. When creating a new job, this will be saved as the default value. |
idealPartTime | integer or null (milliseconds) Default: null The ideal amount of time in milliseconds it takes for one part to be produced. When creating a new job, this will be saved as the default value. |
expectedPartTime | integer or null (milliseconds) Default: null The amount of time in milliseconds it is expected for a part to be produced. When creating a new job, this will be saved as the default value. |
Responses
Request samples
- Payload
{- "erpJobOperationRunId": "01",
- "erpMachineId": "2",
- "startInSetup": false,
- "startAt": "2017-10-10T10:11:00.000Z",
- "jobName": "Spacely Sprockets",
- "jobOperationDescription": "Sprockets for Spacely Space Sprockets, Inc.",
- "lotName": null,
- "partName": "Sprocket001",
- "quantityRequired": 1000,
- "expectedSetupTime": 600,
- "expectedPartTime": 120000,
- "idealPartTime": 100000
}
Response samples
- 200
- 400
- 401
- 403
- 404
null
Get job run
Gets data for a specified job run.
Authorizations:
query Parameters
erpRunId required | string Specified job run ERP ID |
Responses
Response samples
- 200
- 400
- 401
- 403
- 404
{- "startAt": "2017-03-09T18:20:18.000Z",
- "endAt": null,
- "metrics": {
- "totalParts": 2069,
- "goodParts": 2069,
- "scrapParts": 0,
- "nonconformParts": 0
}
}
Stop job run
Stops a job run on a machine.
Authorizations:
Request Body schema: application/jsonrequired
erpJobOperationRunId required | string Unique ID used by the ERP to identify this job run. |
endAt | string or null <date-time> The UTC time the specified job run ended. If no value is provided, the default value is the time the request is received. |
Responses
Request samples
- Payload
{- "erpJobOperationRunId": "01",
- "endAt": "2017-10-10T10:11:00.000Z"
}
Response samples
- 200
- 400
- 401
- 403
- 404
null
Import jobs via file
Creates jobs from list via file - format is specified in request.
Authorizations:
query Parameters
type | string Default: "mm" Enum: "mm" "inforVisual" "inforLN" The format of the jobs file being imported. Acceptable values are
If no value is provided, job import will be assumed to be in the MachineMetrics format. You can find more information about that format, as well as a template, here. |
Request Body schema: multipart/form-datarequired
csvFile required | string <binary> The CSV file being imported. |
autoArchive | boolean Default: false Set this to true if you want to archive all jobs that are not included in the CSV File |
Responses
Response samples
- 200
- 400
- 401
- 403
- 404
null
Get scheduled time during a time window for a given machine
Authorizations:
query Parameters
startAt required | string <date-time> Start of the time window. ISO 8601 format. |
endAt required | string <date-time> End of the time window. ISO 8601 format. |
Responses
Response samples
- 200
- 400
- 404
{ }