# FunctionX status API
Author: IoT Open Developer
# Background
Simple introduction to customer that wants to get data from the FunctionX status api.
# Prerequisites
You are probably used to using the IoT Open web interface and knows what an Installation and Function is, if not read the introduction and get an account on IoT Open.
You will need an API key to a user connected to the installation you want to get data from. See this guide. Once you have the key you are ready to go.
# The Status API
The status API is mostly intended to get the latest known values for each topic and are often used to get the current value for each function. The response below have all the values this installation has reported, and their latest timestamps.
$ curl -u token:f0b96ad8dbeae0569f37f9b4b5ba0429 https://lynx-demo.iotopen.se/api/v2/status/4
[
{
"timestamp": 1588853086,
"client_id": 4,
"installation_id": 4,
"topic": "obj/ow/goteborg/humidity",
"value": 41,
"msg": "u62823u31"
},
{
"timestamp": 1588853086,
"client_id": 4,
"installation_id": 4,
"topic": "obj/ow/goteborg/pressure",
"value": 1017,
"msg": "u62823u31"
},
{
"timestamp": 1588853086,
"client_id": 4,
"installation_id": 4,
"topic": "obj/ow/goteborg/temperature",
"value": 14.68,
"msg": "u62823u31"
},
{
"timestamp": 1588852823,
"client_id": 4,
"installation_id": 4,
"topic": "obj/ow/stockholm/humidity",
"value": 37,
"msg": "u6scdbwyk"
},
{
"timestamp": 1588852823,
"client_id": 4,
"installation_id": 4,
"topic": "obj/ow/stockholm/pressure",
"value": 1015,
"msg": "u6scdbwyk"
},
{
"timestamp": 1588852823,
"client_id": 4,
"installation_id": 4,
"topic": "obj/ow/stockholm/temperature",
"value": 11.48,
"msg": "u6scdbwyk"
}
]
That should be all you need to get you started, but please read on.
In your code you need to parse the json-objects to get what you need. If you only want to get one function then you may filter on the topic. Note: The topic needs to include the Client ID. Note 2: the Client ID is not equal to the Installation ID even though it happens to be so in the example below.
$ curl -u token:f0b96ad8dbeae0569f37f9b4b5ba0429 https://lynx-demo.iotopen.se/api/v2/status/4?topics=4/obj/ow/stockholm/temperature
[
{
"timestamp": 1588858746,
"client_id": 4,
"installation_id": 4,
"topic": "obj/ow/stockholm/temperature",
"value": 11.76,
"msg": "u6scdbwyk"
}
]
# How do I know what I get?
The information about the function is in metadata belonging to that function. You can see this metadata in the IoT Open web interface or via the FunctionX API, like this.
$ curl -u token:f0b96ad8dbeae0569f37f9b4b5ba0429 https://lynx-demo.iotopen.se/api/v2/functionx/4
[
{
"id": 49,
"type": "temp",
"installation_id": 4,
"updated": 1587630732,
"created": 1587630732,
"meta": {
"format": "%.1f°C",
"icon": "thermometer",
"landsdel": "Götaland",
"name": "Göteborg Temperature",
"topic_read": "obj/ow/goteborg/temperature"
}
},
{
"id": 52,
"type": "pressure",
"installation_id": 4,
"updated": 1587630733,
"created": 1587630733,
"meta": {
"format": "%.1f",
"icon": "gauge",
"landsdel": "Götaland",
"name": "Göteborg Pressure",
"topic_read": "obj/ow/goteborg/pressure"
}
},
{
"id": 55,
"type": "humidity",
"installation_id": 4,
"updated": 1587630733,
"created": 1587630733,
"meta": {
"format": "%.1f",
"icon": "gauge",
"landsdel": "Götaland",
"name": "Göteborg Humidity",
"topic_read": "obj/ow/goteborg/humidity"
}
},
{
"id": 58,
"type": "temp",
"installation_id": 4,
"updated": 1587630734,
"created": 1587630734,
"meta": {
"format": "%.1f°C",
"icon": "thermometer",
"landsdel": "Svealand",
"name": "Stockholm Temperature",
"topic_read": "obj/ow/stockholm/temperature"
}
},
{
"id": 61,
"type": "pressure",
"installation_id": 4,
"updated": 1587630735,
"created": 1587630735,
"meta": {
"format": "%.1f",
"icon": "gauge",
"landsdel": "Svealand",
"name": "Stockholm Pressure",
"topic_read": "obj/ow/stockholm/pressure"
}
},
{
"id": 64,
"type": "humidity",
"installation_id": 4,
"updated": 1587630736,
"created": 1587630736,
"meta": {
"format": "%.1f",
"icon": "gauge",
"landsdel": "Svealand",
"name": "Stockholm Humidity",
"topic_read": "obj/ow/stockholm/humidity"
}
}
]