Your first API request
Go from an IRIS Cloud account to your first machine query in a few steps.
Before you start#
- An IRIS Cloud account with access to your organization.
- An API token created in User Account → IRIS Cloud API Tokens. Follow the token guide.
- A terminal with cURL, or use the interactive API reference.
Make your first request#
Make your token available as the environment variable CONNECT_API_TOKEN. In Bash, the following prompt keeps the token out of your command history:
read -r -s -p 'Connect API token: ' CONNECT_API_TOKEN
printf '\n'
export CONNECT_API_TOKENRequest the machines available to your organization:
curl --request GET \
--url 'https://connect-api.iris-cloud.netzsch.com/api/v1/machines' \
--header "Authorization: Bearer $CONNECT_API_TOKEN" \
--header 'Accept: application/json'The token is sent in the Authorization header. Do not put it in the URL.
Read the response#
A successful request returns 200 OK and JSON. This shortened, illustrative response shows the data array:
{
"data": [
{
"id": "machine-example",
"name": "Production mill",
"status": "IDLE"
}
]
}Use a machine’s id in subsequent requests. An empty data array means this request returned no visible machines; it is not an authentication error. See the reference for the complete response schema.
Discover the sensors#
Replace MACHINE_ID with an ID returned by your machine query.
curl 'https://connect-api.iris-cloud.netzsch.com/api/v1/machines/MACHINE_ID/sensors' \
--header "Authorization: Bearer $CONNECT_API_TOKEN"Then read a snapshot or query historical measurements. If your first request fails, use the troubleshooting guide.