Making your first API call
In this guide, we will walk you through the process of making your first API request. We will begin by showing you how to retrieve a list of all your assets (Buildings, Floors, Rooms, Desks, etc.), and then we will demonstrate how to retrieve sensor data from some of these assets using the Query API endpoint.
Prerequisite
Please note that the following API calls require you to make an authenticated call to the Relynks API. If you haven't already, please follow the Authentication guide to learn more about our API authentication process.
Retrieving a list of all your assets
To retrieve a list of all your assets, you will need to make a GET request to the endpoint '/asset/list'. Here is an example of how to make this request using cURL:
curl -X GET \
https://api.relynk.io/asset/list \
-H 'accept: application/json' \
-H 'authorization: YourAPIKey' \
-d asNestedObjects=true
Please make sure to replace 'YourAPIKey' with the actual value of your API key.
This request will return a list of all your assets as a nested object (as an example, a buildings will have its floors as children and the rooms as childrens of the floors etc.). The response will follow the schema specified below:
If you want all the assets to be returned as a one-dimensional array, you can set the asNestedObjects parameter to false.
To view the full documentation for the Asset List API endpoint, please visit API Reference - Asset GetMany Endpoint.
Retrieving sensor data using the Query API endpoint
Once you have a list of assets, you can create a query request to retrieve sensor data and filter the results to only retrieve data from specific assets.
Read the Relationship between sensors and assets deep dive to understand how sensors are related to the assets.
In this example, we will retrieve the average temperature and presence data from all the rooms on the 4th floor of a building, from the 1st of January at a 1-hour resolution.
First, you will need to retrieve the asset ID of the 4th floor. You can do this by looking at the data from the previous request you made to '/asset/list' and locate the 4th floor. Once you have the ID, you can make the following POST request to the '/query' endpoint:
curl -X 'POST' \
'https://api.relynk.io/query' \
-H 'accept: application/json' \
-H 'authorization: YourAPIKey' \
-H 'Content-Type: application/json' \
-d '{
"filters": [
{
"filter_on": "asset_id",
"value": [
YourFloorId
]
},
{
"filter_on": "measurement",
"value": [
"Presence", "Temperature"
]
}
],
"group_on": "Room",
"resolution": "1 hour",
"is_timeseries": true,
"only_latest_value": false,
"to": "2023-01-02T00:00:00+01:00",
"from": "2023-01-01T00:00:00+01:00"
}'
Make sure to replace 'YourAPIKey' with the actual value of your API key, and 'YourFloorId' with the actual value of the floor id.
This will return a list of all the rooms on the 4th floor with the average temperature and presence data from the 1st of january at a 1 hour resolution with the following schema:
Read the Querying data deep dive to learn more about the Query API endpoint.
To view the full for the Query API endpoint, please visit the API Reference - Query Endpoint page.
API Reference
To view all the actions you can perform with the Relynks API, please visit the API Reference page.